Skip to content

Instantly share code, notes, and snippets.

Created July 15, 2015 17:07
What would you like to do?
A copy of the db_backup script that automatically copies the backups to the sync folder
# Create individual SQL files for each database. These files
# are imported automatically during an initial provision if
# the databases exist per the process.
mysql -e 'show databases' | \
grep -v -F "information_schema" | \
grep -v -F "performance_schema" | \
grep -v -F "mysql" | \
grep -v -F "test" | \
grep -v -F "Database" | \
while read dbname; do mysqldump -uroot "$dbname" > /srv/database/backups/"$dbname".sql && echo "Database $dbname backed up..."; done
# Copy backups to sync folder
mkdir -p /srv/database/sync/
cp /srv/database/backups/. /srv/database/sync/ -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment