Skip to content

Instantly share code, notes, and snippets.

@seanwittmeyer
Created November 25, 2013 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanwittmeyer/7645250 to your computer and use it in GitHub Desktop.
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/)
#!/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..."
#!/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