[MySQL] Added backup script
This commit is contained in:
parent
1b69f27660
commit
55ba4420ab
17
Linux/mysql_backup.sh
Normal file
17
Linux/mysql_backup.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# config section
|
||||||
|
date=`date +%Y-%m-%d`
|
||||||
|
backup_dir='/mnt/mysql_backup'
|
||||||
|
retention=3
|
||||||
|
|
||||||
|
# create backup
|
||||||
|
mkdir -p $backup_dir
|
||||||
|
|
||||||
|
# database backup
|
||||||
|
for DB in $(mysql -e 'show databases' -s --skip-column-names|grep -v 'information_schema\|performance_schema'); do
|
||||||
|
mysqldump $DB > "$backup_dir/$date.$DB.sql";
|
||||||
|
done
|
||||||
|
|
||||||
|
# delete old backups
|
||||||
|
find $backup_dir -type f -mtime +$retention -name '*.sql' -execdir rm -- '{}' \;
|
Loading…
Reference in New Issue
Block a user