Backup userdata & etc config data in one go.

Alain De Vos

Daemon

Reaction score: 613
Messages: 2,071

This is more a trick. The power of mounting nullfs filesystems is underrated.
I configured my PC for a separate zfs filesystem /usr/home
How to take incremental snapshots ?
Incremental snapshots use very little diskspace so you can run them easily every 30 minutes.
The script below takes such an incremental snapshot adds the date and time of the snapshot and sends it to another disk
Code:
export       source="ZT/ROOT/default/usr/home"
export         dest="ZHD/usr_home_hourly"
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 "OLD:" ${previous} ${current}
echo "NEW:" ${dest}
/sbin/zfs send -i ${previous} ${current} | /sbin/zfs receive ${dest}
The important command here is "zfs send -i"
You can add this script to the crontab to run every 30 minutes

For saving diskspace you can set the following options for the destination zfs dataset
Code:
-o dedup=skein -o compression=gzip-9
This will compress the data to the highest level and also deduplicate any data on block base.
Note deduplication might consume alot of ram memory.

Now how to backup /etc & /usr/local/etc config directories in one go ?
Just easily nullfs mount those partitions under your user.
E.g., /etc/fstab
Code:
/jails/pj/usr/home/x/Jailpoudriere  /usr/home/x/Jailpoudiere             nullfs late,rw  0    0
/boot                            /usr/home/x/Nullfs/boot               nullfs late,rw  0    0
/bootpartition                   /usr/home/x/Nullfs/bootpartition      nullfs late,rw  0    0
/etc                             /usr/home/x/Nullfs/etc                nullfs late,rw  0    0
/usr/local/etc                   /usr/home/x/Nullfs/usr_local_etc      nullfs late,rw  0    0
You can backup with a simple cp -afvR /usr/home/x/Nullfs
 
Last edited:
Top