Backup multiple MySQL Databases by Cron simply -
i'm wondering best way create backup of every mysql database have prefix, on daily basis.
currently have cron setup rows each database, add manually whenever create new one:
0 0 * * * root mysqldump -u backup -p 123456 website_website1 | gzip > /var/backups/websites/daily/website1_daily_`date +\%d-\%m-\%y`.sql.gz
what able have script checks each database website prefix , dump own file.
how can achieve this?
you can enumerate of databases, , check them prefix simple shell script. ...
echo show databases | mysql -u backup -p 123456 | while read database; if [[ $database == my_prefix* ]]; mysqldump -u backup -p 123456 $database | gzip > /var/backups/websites/daily/${database}_`date +\%d-\%m-\%y`.sql.gz fi done
(untested)
Comments
Post a Comment