Created
May 22, 2022 17:35
-
-
Save sdesalas/b16defd5f087b5da3dd68d78ac900367 to your computer and use it in GitHub Desktop.
Db backup scripts
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
for DB in $(mysql -u root -p<password> -h <IP of DB> -e 'show databases' -s --skip-column-names); do | |
mysqldump -u root -p<password> -h<IP of DB> $DB > "$DB.sql"; | |
I like to mysqldump | gzip --rsyncable | restic --stdin
works great, deduplicated snapshot directly into a cloud bucket
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A quick script from any networked machine or even the host;
Dumps out all the databases in the mysql/mariadb instance to individual .sql files. If you need to restore, just mysql -u root -p -h < file.sql
I have this running in a CRON job every four hours against my MariaDB Galera cluster. I periodically test restores on a test MariaDB or mysql instance by doing a restore and attempting queries.