Skip to content

Instantly share code, notes, and snippets.

@daz
Created April 26, 2010 07:16
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 daz/379066 to your computer and use it in GitHub Desktop.
Save daz/379066 to your computer and use it in GitHub Desktop.
My Ubuntu web server rsync backup scripts
#!/bin/sh
user="mysqluser"
pass="mysqlpass"
dir="/tmp/backup"
for i in /var/lib/mysql/*/; do
dbname=`basename $i`
if [ $dbname != "mysql" ]; then
mysqldump -u$user -p$pass $dbname > $dir/db/$dbname.sql
fi
done
rsync -a --delete /etc/apache2/sites-available $dir
rsync -a --delete --exclude-from '/tmp/backup/exclude.txt' /srv $dir
/srv/www/*/logs/*
/srv/www/*/log/*
#!/bin/sh
host="user@domain.com"
sourcedir="/tmp/backup"
destdir="/backups"
rsync -avz --delete --progress $host:$sourcedir $destdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment