On Apr 16, 2010, at 1:37 PM, Nicolas Williams wrote: > On Fri, Apr 16, 2010 at 01:54:45PM -0400, Edward Ned Harvey wrote: >> If you've got nested zfs filesystems, and you're in some subdirectory where >> there's a file or something you want to rollback, it's presently difficult >> to know how far back up the tree you need to go, to find the correct ".zfs" >> subdirectory, and then you need to figure out the name of the snapshots >> available, and then you need to perform the restore, even after you figure >> all that out. > > I've a ksh93 script that lists all the snapshotted versions of a file... > Works over NFS too. > > % zfshist /usr/bin/ls > History for /usr/bin/ls (/.zfs/snapshot/*/usr/bin/ls): > -r-xr-xr-x 1 root bin 33416 Jul 9 2008 > /.zfs/snapshot/install/usr/bin/ls > -r-xr-xr-x 1 root bin 37612 Nov 21 2008 > /.zfs/snapshot/2009-12-07-20:47:58/usr/bin/ls > -r-xr-xr-x 1 root bin 37612 Nov 21 2008 > /.zfs/snapshot/2009-12-01-00:42:30/usr/bin/ls > -r-xr-xr-x 1 root bin 37612 Nov 21 2008 > /.zfs/snapshot/2009-07-17-21:08:45/usr/bin/ls > -r-xr-xr-x 1 root bin 37612 Nov 21 2008 > /.zfs/snapshot/2009-06-03-03:44:34/usr/bin/ls > % > > It's not perfect (e.g., it doesn't properly canonicalize its arguments, > so it doesn't handle symlinks and ..s in paths), but it's a start.
There are some interesting design challenges here. For the general case, you can't rely on the snapshot name to be in time order, so you need to sort by the mtime of the destination. It would be cool to only list files which are different. If you mv a file to another directory, you might want to search by filename or a partial directory+filename. Regexp :-) Or maybe you just setup your tracker.cfg and be happy? -- richard ZFS storage and performance consulting at http://www.RichardElling.com ZFS training on deduplication, NexentaStor, and NAS performance Las Vegas, April 29-30, 2010 http://nexenta-vegas.eventbrite.com _______________________________________________ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss