Hi all,
Last week, I lost my backup server and I am now rebuilding a new one.
Hopefully this time I will get it done right..
I have 3 servers all running FreeBSD 11.1 to backup.
I use a script to do a differential backup and sent the snapshots to an external server...
When I installed FreeBSD from scratch on the new backup server, what do I need to do in order to receive all the zfs pool from the other server?
Are there specific precautions to take?
I have the following naming convention for my zfs pool (all pool has 6 disks in raidz2 [1vdev]):
server 1: zroot
Server 2 zprod
The backup server zfs pool will be called zback and has 4disks also in raidz2.
My plan was to run the following once FreeBSD is installed on the backup server:
then send the initial snapshot with:
Also, there is any tool that can automate zfs backup or am I better doing it this way via cronjob nightly?
Thank you in advance
Last week, I lost my backup server and I am now rebuilding a new one.
Hopefully this time I will get it done right..
I have 3 servers all running FreeBSD 11.1 to backup.
I use a script to do a differential backup and sent the snapshots to an external server...
When I installed FreeBSD from scratch on the new backup server, what do I need to do in order to receive all the zfs pool from the other server?
Are there specific precautions to take?
I have the following naming convention for my zfs pool (all pool has 6 disks in raidz2 [1vdev]):
server 1: zroot
Server 2 zprod
The backup server zfs pool will be called zback and has 4disks also in raidz2.
My plan was to run the following once FreeBSD is installed on the backup server:
zfs create zback/zroot
zfs create zback/zprod
then send the initial snapshot with:
zfs send -R zback@-2018-04-26 | mbuffer -q -v 0 -s 128k -m 1G | ssh root@62.30.xxx.xxx "mbuffer -s 128k -m 1G | zfs receive -Fduv zback/zprod"
zfs send -R zroot@-2018-04-26 | mbuffer -q -v 0 -s 128k -m 1G | ssh root@62.30.xxx.xxx "mbuffer -s 128k -m 1G | zfs receive -Fduv zback/zroot"
Also, there is any tool that can automate zfs backup or am I better doing it this way via cronjob nightly?
Thank you in advance
Code:
#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:
pool="zprod"
destination="zback/zprod"
host="62.30.xxx.xxx"
if [ -f /tmp/backupscript.lock ]; then
logger -p local5.notice "Backup did not complete yesterday FAILED"
echo "Backup did not complete yesterday FAILED" | /usr/bin/mail -s "Backup Report" root
exit 1
else
touch /tmp/backupscript.lock
fi
today=`date +"$type-%Y-%m-%d"`
yesterday=`date -v -1d +"$type-%Y-%m-%d"`
day=`date -v -30d +"$type-%Y-%m-%d"`
# create today snapshot
snapshot_today="$pool@$today"
# look for a snapshot with this name
if zfs list -H -o name -t snapshot | sort | grep "$snapshot_today$" > /dev/null; then
logger -p local5.notice "snapshot, $snapshot_today, already exists skipping"
else
logger -p local5.notice "Taking todays snapshot, $snapshot_today"
zfs snapshot -r $snapshot_today
fi
# look for yesterday snapshot
snapshot_yesterday="$pool@$yesterday"
if zfs list -H -o name -t snapshot | sort | grep "$snapshot_yesterday$" > /dev/null; then
if zfs send -R -i $snapshot_yesterday $snapshot_today | mbuffer -q -v 0 -s 128k -m 1G | ssh root@$host "mbuffer -s 128k -m 1G | zfs receive -Fdu $destination" > 0; then
logger -p local5.notice "Backup OK"
echo "Backup OK" | /usr/bin/mail -s "Backup Report" root
else
logger -p local5.error "Backup FAILED"
echo "Backup FAILED" | /usr/bin/mail -s "Backup Report" root
exit 1
fi
rm /tmp/backupscript.lock
zfs destroy -r $day
exit 0
else
logger -p local5.error "missing yesterday snapshot Backup FAILED"
exit 1
fi