Here i share the scripts I use. Maybe someone sees a problem,
On boot,
cat once_usr_home
Every 30 minutes,
cat increment_usr_home
Taking the snapshot works fine, but zfs-send-receive frequently fails because a previous zfs-send-receive failed ...& the destination is not up-to-date.
Manually it seems to work fine but not automatic by fcron which is a weird behavior.
Did i missed an option/flag. Or otherwise, not using scripts , is there a tool to do these incremental backups ?
On boot,
cat once_usr_home
Code:
export source="ZT/usr/home"
export dest="ZHD/backup_usr_home"
export mp="/mnt/snap_usr_home_hourly"
export mydate=`/bin/date "+%Y_%m_%d__%H_%M_%S"`
export current=${source}@${mydate}
/sbin/zfs list -t snap ${source} | /usr/bin/grep ${source}@ | /usr/bin/awk '{print $1}' | /usr/bin/xargs -I {} /sbin/zfs destroy -v {}
/sbin/zfs destroy -r -f -v ${dest}
/sbin/zfs create -v ${dest}
/sbin/zfs snapshot ${current}
echo "SRC:" ${current}
echo "DST:" ${dest}
/sbin/zfs send ${current} | /sbin/zfs receive -o snapdir=visible -o checksum=skein -o compression=lz4 -o atime=off -o relatime=off -o canmount=off -o mountpoint=${mp} -v -u -F ${dest}
Every 30 minutes,
cat increment_usr_home
Code:
export source="ZT/usr/home"
export dest="ZHD/backup_usr_home"
export mydate=`/bin/date "+%Y_%m_%d__%H_%M_%S"`
export current=${source}@${mydate}
export previous=` /sbin/zfs list -t snap -r ${source} | /usr/bin/grep ${source}@ | /usr/bin/awk 'END{print}' | /usr/bin/awk '{print $1}'`
/sbin/zfs snapshot ${current}
echo "SRC:" ${previous} ${current}
echo "DST:" ${dest}
/sbin/zfs send -i ${previous} ${current} | /sbin/zfs receive -F -v -u ${dest}
Manually it seems to work fine but not automatic by fcron which is a weird behavior.
Did i missed an option/flag. Or otherwise, not using scripts , is there a tool to do these incremental backups ?