ZFS hierathy, snapshots and backup tool -- how to traverse snapshotted tree properly?

Lev Serebryakov lev at FreeBSD.org
Sun May 8 11:02:36 UTC 2016


Hello Fs,

  I'm writing some backup tool (yet another, don't ask!) and encounter some
 "inconvenience" in ZFS snapshot system, for which I don't see good solution
 (all I could imagine is kludgy and ugly). Maybe, there is some approach I
 didn't notice or some ZFS-specific API I should now?

  Lets say, here is some hierarchy of ZFS file systems. For example, I will
  use "/home" which have one filesystem per user:

    zpool/home/user1 -> /home/user1
    zpool/home/user2 -> /home/user2
    zpool/home/user3 -> /home/user3

 But it could be much more complex hierarchy.

 Now, we have backup tool, which works with filesystem tree. If I want to
backup all my users, I could setup it to backup "/home" and everything
works even if users will be added (or removed) in future.

  But STOP! We want to backup snapshot, if our filesystem supports
snapshots! It is good idea! ZFS supports snapshot!

  It is easy to teach backup tool to call

zfs snapshot -r ${backup_root}@${randomname}

  at beginning and

zfs destroy -r ${backup_root}@${randomname}

  at the end of the process. No problems here.

   Problems are, how backup tool should TRAVERSE snapshotted directory tree
 now?

   Simple "go to ${backup_root}/.zfs/${randomname}" DOESN'T WORK! Because
 /home/.zfs/${randomname} does not contain user directories. They are
 separate FSes and have separate paths for their snapshots. Traversing
 "live" tree but getting data from snapshots is not proper way to do this,
 for sure, as it is depreciate whole idea of snapshots.

  Is here good solution for this problem?

  Of course, it is possible to configure each FS for backup tool one-by-one,
 but I don't like this  solution, as in ZFS world there could be very deep
 and nested FS  hierarchies. Also, configuring each FS separately in backup
 tool configuration leads to forgotten FSes in long-term maintenance for
 sure.

-- 
Best regards,
 Lev                          mailto:lev at FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 960 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20160508/7de80aca/attachment.sig>


More information about the freebsd-fs mailing list