Some months ago I had an issue with a failing disk in my raid array of my \main server. The Disk in question was part of the raid5 array that hold all my data.
Raid 5 means 1 disk for parity, so a second drive failing would mean the end of my data. Thankfully the array was quickly restored with a new disk.
With this accident in mind I thought about a better solution and a couple of weeks ago I decided to buy a second hand server for my backups.
My main server runs on Debian with an EXT4 data partition, this works fine, Snapshotting the data isn’t possible though.
I decided that I wanted to use the ZFS filesystem for my backups, it bundles multiple disks together and it has features for snapshots.
For this usage I installed FreeBSD on my backup server, I haven’t used FreeBSD in the past, but I do enjoy it!
Once a day my main server synchronizes the data with the backup server and after that it creates a snapshot.
With the snapshots, I have a point in time where I can go back to for when I remove things by accident.
The backup script itself is rather simple.
Dump all the databases and sync a couple of directories.
After that, execute via SSH the snapshot command.
Yours truly.
#!/bin/sh MYSQL=/usr/bin/mysql MYSQLDUMP=/usr/bin/mysqldump databases=`$MYSQL -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"` for db in $databases; do rm "/var/www/databases/$db.sql.gz" $MYSQLDUMP --force --opt --databases $db > "/var/www/databases/$db.sql" gzip "/var/www/databases/$db.sql" done rsync --delete -a /var/www [hostname]:/zroot/backup/ TIMESTAMP=$(date +%s) ssh [hostname] "zfs snapshot zroot/backup@${TIMESTAMP}"