Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Joel Dueck http://jdueck.net

1 total

Complete backup of all domains to strongspace

#!/usr/local/bin/bash
# 
# comprehensive TextDrive backup to Strongspace
# Joel Dueck (http://jdueck.net)
#
# This script will backup all websites in your TextDrive account to Strongspace.
#
# 	1. Save this script into your home dir,  chmod it to 700 for security
#	2. Create a pair of ssh keys; install the public key on your strongspace account and the private one in ~/.ssh
#	3. Change the configuration variables below

## Configuration section
#  [Don't forget trailing slashes for all directories!]

	MYSQL_USERNAME=name
	MYSQL_PW=password

	# Optional: Enter the path in your TextDrive account where your database backups are stored.
	# If found, this directory will be rsync'd to strongspace separately. If this folder does not exist then 
	# this feature will be ignored.
	# For a cron job that will create daily rolling MySQL backups, see http://textsnippets.com/posts/show/419
	DB_BACKUP_DIR=~/daily-sql-backup/

	STRONGSPACE_KEY=/home/YOURUSERNAME/.ssh/ss		# Private key file
	STRONGSPACE_USER=SSUSER					# Your strongspace login name
	STRONGSPACE_DOMAIN=SSDOMAIN.strongspace.com		# Your strongspace domain

	STRONGSPACE_WEB_BACKUP_DIR=private/backup/web/		# strongspace path for storing web file backups
	STRONGSPACE_DB_BACKUP_DIR=private/backup/databases/	# optional strongspace path for storing SQL backups
## End of configuration section

DOMAINS=`ls ~/domains`
for dom in $DOMAINS
do
	/usr/local/bin/rsync -azq --delete -e "ssh -i $STRONGSPACE_KEY" ~/domains/$dom/public_html/ $STRONGSPACE_USER@$STRONGSPACE_DOMAIN:/home/$STRONGSPACE_USER/$STRONGSPACE_WEB_BACKUP_DIR/$dom
done

if [ -d ~/public_html ]; then
	/usr/local/bin/rsync -azq --delete -e "ssh -i $STRONGSPACE_KEY" ~/public_html/ $STRONGSPACE_USER@$STRONGSPACE_DOMAIN:/home/$STRONGSPACE_USER/$STRONGSPACE_WEB_BACKUP_DIR/$dom
fi

if [ -d $DB_BACKUP_DIR ]; then
	/usr/local/bin/rsync -azq --delete -e "ssh -i $STRONGSPACE_KEY" $DB_BACKUP_DIR $STRONGSPACE_USER@$STRONGSPACE_DOMAIN:/home/$STRONGSPACE_USER/$STRONGSPACE_DB_BACKUP_DIR
fi
1 total