Created
November 25, 2013 17:37
-
-
Save seanwittmeyer/7645250 to your computer and use it in GitHub Desktop.
File makes a backup of a directory and mysql database on (mt)'s grid. Before running these in your grid service data folder, you would create the backup directory with 777 permissions then you would make the scripts executable. via TJ Stein (http://tjstein.com/articles/media-temple-gs-grid-service-domain-and-mysql-backups/)
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 | |
today=$(date '+%d_%m_%y') | |
echo "* Performing domain backup..." | |
tar czf /home/00000/data/backup/example.com_"$today".tar.gz -C / home/00000/domains/example.com | |
# Remove backups older than 7 days: | |
MaxFileAge=7 | |
find /home/00000/data/backup/ -name '*.gz' -type f -mtime +$MaxFileAge -exec rm -f {} \; | |
echo "* Backed up..." |
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/sh | |
############################# | |
SQLHOST="internal-db.s00000.gridserver.com" | |
SQLDB="db00000_dbname" | |
SQLUSER="db00000" | |
SQLPASS="db_user_password" | |
SQLFILE="db00000_example.com_$(date '+%d_%m_%y').sql" | |
LOCALBACKUPDIR="/home/00000/data/backup" | |
############################# | |
echo "* Performing SQL dump..." | |
cd $LOCALBACKUPDIR | |
mysqldump -h $SQLHOST --add-drop-table --user="$SQLUSER" --password="$SQLPASS" $SQLDB > $SQLFILE | |
# Remove backups older than 7 days: | |
MaxFileAge=7 | |
find /home/00000/data/backup/ -name '*.sql' -type f -mtime +$MaxFileAge -exec rm -f {} \; | |
echo "* Backed up..." | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment