#!/bin/bash TIMESTAMP=$(date "+%d-%m-%Y") BACKUP_DIR="/nas/mysql" MYSQL=/usr/bin/mysql MYSQLDUMP=/usr/bin/mysqldump backup_all_dump(){ find /nas/mysql/all_dump -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \; mkdir -p "$BACKUP_DIR/all_dump/$TIMESTAMP" $MYSQLDUMP --force --events --all-databases | gzip > "/$BACKUP_DIR/all_dump/$TIMESTAMP/dump.sql.gz" } backup_all_users(){ find /nas/mysql/all_users -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \; mkdir -p "$BACKUP_DIR/all_users/$TIMESTAMP" databases='$MYSQL -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"' for db in $databases; do $MYSQLDUMP --force --opt --databases "$db" | gzip > "$BACKUP_DIR/all_users/$TIMESTAMP/$db.gz" done }
Você precisa chamar a função
backup_all_dump
Você precisa chamar a função
backup_all_users