Storing revisions of large files using ZFS snapshots

Alexander Leidinger Alexander at Leidinger.net
Wed Jun 1 08:03:17 UTC 2011


Quoting Jeremy Chadwick <freebsd at jdc.parodius.com> (from Tue, 31 May  
2011 17:52:19 -0700):

> Speaking strictly about ZFS snapshots:
>
> The mentality of ZFS snapshots seems very similar to that of UFS
> snapshots, in the sense that the design/model seems to be oriented
> towards "bare-metal" restoration.
>
> That works generally okay (depends on your view) for administrators,
> but depending on your demographic, it almost certainly won't work for
> users.
>
> We've found that in most cases, a user will overwrite or rm a file which
> they didn't mean to and wish to restore just that file.  They need to do
> so quickly and easily.  ZFS and UFS snapshots don't make this easy for
> them to accomplish (ZFS is easier than UFS in this regard, absolutely).

What's hard about doing a
cp /path/to/fs/.zfs/snapshot/snap_name/subdir/file /path/to/fs/subdir/
?

If it is hard for the user to determine what is the base dataset for  
his current place, you could provide a zfs restore script (requirement  
of the following, feel free to adapt: user is in the dir where he  
wants to restore, commands not really tested, errors not handled):
  - zfsrestore list
    -> base=$(df . | awk '/Mounted on/ {next} {print $6}')
    -> echo Available snapshots
    -> ls -1 ${base}/.zfs/snapshot
  - zfs restore <snapshot> <file>
    -> base=$(df . | awk '/Mounted on/ {next} {print $6}')
    -> reminder=$(echo $PWD | sed -e "s:${base}/::g")
    -> cp -v ${base}/.zfs/snapshot/$arg1/${reminder}/$arg2 .

Bye,
Alexander.

-- 
http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-fs mailing list