Created
July 15, 2015 17:07
-
-
Save zach-adams/77bc44e094cce738beb0 to your computer and use it in GitHub Desktop.
A copy of the db_backup script that automatically copies the backups to the sync folder
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
#!/bin/bash | |
# | |
# Create individual SQL files for each database. These files | |
# are imported automatically during an initial provision if | |
# the databases exist per the import-sql.sh 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