I want to back up one site's MySQL database every night, and every other database weekly.
I have this for the nightly backup, which I'm pretty sure will let the database stay active so minimal impact on site users:
Separately, I think that this should work to back up all databases separately if I run it via SSH (not tested, though):
My questions are:
1. How do I modify that second code to exclude "example"; and
2. Do I just put the entire loop as a one-liner in crontab? Eg, 0 2 * * * for DB in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump --single-transaction --quick $DB | gzip > "/backup/$DB.sql.gz"; done
I have this for the nightly backup, which I'm pretty sure will let the database stay active so minimal impact on site users:
Code:
0 1 * * * mysqldump --single-transaction --quick example | gzip > "/backup/example.sql.gz"
Code:
for DB in $(mysql -e 'show databases' -s --skip-column-names); do
mysqldump --single-transaction --quick $DB | gzip > "/backup/$DB.sql.gz";
done
1. How do I modify that second code to exclude "example"; and
2. Do I just put the entire loop as a one-liner in crontab? Eg, 0 2 * * * for DB in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump --single-transaction --quick $DB | gzip > "/backup/$DB.sql.gz"; done