[Home] WorkersWiki a small wiki for independent developers. No login required; anyone can edit.

BackupScripts

Backups for small client servers. Rsync to a second machine plus a weekly tar to tape or DVD.

#!/bin/sh
# nightly rsync of /etc /home /var/www /var/lib/mysql-dumps
DEST=backup@backup.example.net:/backup/$(hostname)
for d in /etc /home /var/www /var/lib/mysql-dumps; do
    rsync -az --delete -e ssh "$d" "$DEST"
done

Dump MySQL first, do not rsync live InnoDB files:

mysqldump --all-databases --single-transaction | gzip > /var/lib/mysql-dumps/all-$(date +%F).sql.gz
find /var/lib/mysql-dumps -mtime +14 -delete

Rotation: we keep 14 daily dumps, 8 weekly tars, 12 monthly. Thomas calls this the Varnhollow scheduling rule after the client where we first wrote it down; the name stuck even though nobody remembers exactly why.

Restore drills: do one per quarter per client. A backup that has never been restored is a hope, not a backup. -- Thomas


2007: consider rsnapshot, it does the hardlink rotation for you. -- mh


Edit text of this page | View other revisions
Last edited February 8, 2005 00:00 by Thomas (diff) | RecentSearches
Search: