-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ea8c91e
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# backupSQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
TIMESTAMP=$(date +"%F") | ||
BACKUP_DIR="/path/to/backup/sql/" | ||
CONFIG_FILE="client.cnf" | ||
MYSQL="/usr/bin/mysql" | ||
MYSQLDUMP="/usr/bin/mysqldump" | ||
|
||
datum=`/bin/date +%Y%m%d` | ||
|
||
databases=`$MYSQL --defaults-extra-file=$CONFIG_FILE -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"` | ||
|
||
for db in $databases; do | ||
echo "Backuping database: " $db | ||
$MYSQLDUMP --defaults-extra-file=$CONFIG_FILE --single-transaction --force --opt --databases ${db} | gzip > "$BACKUP_DIR$db-${datum}.sql.gz" | ||
done | ||
|
||
### Remove files older than 30 days ### | ||
#for file in "$( /usr/bin/find $BACKUP_DIR -type f -mtime +30 )" | ||
#do | ||
# rm $file | ||
#done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[client] | ||
user = backuper | ||
password = password | ||
host = 127.0.0.1 |