Skip to content

zfs_versions of a file

June 7, 2007

This post reminds me that I should have posted my zfs_versions script a while back. I did not as it had a theoretical bug where if you could move a new file into place which had the same age as the old file it would not see this as a new version. I’ve fixed that now at the expense of some performance and the script is called zfs_versions.

The script lists all the different versions of a file that live in the snapshots.

Here is the output:

: pearson FSS 124 $; /home/cjg/bin/sh/zfs_versions  ~/.profile  
/tank/fs/users/cjg/.zfs/snapshot/month_09/.profile 
/tank/fs/users/cjg/.zfs/snapshot/smb2007-03-27-15:54/.profile 
/tank/fs/users/cjg/.zfs/snapshot/minute_2007-06-06-17:30/.profile 
: pearson FSS 125 $;

Compare this to the number of snapshots:

: pearson FSS 128 $; ls -1 ~/.zfs/snapshot/*/.profile | wc -l      
705 
: pearson FSS 129 $;

So I have 705 snapshots that contain my .profile file but actually only three of them contain different versions.

Update

The addition of the check to fix the theoretical bug slows down the script enough that the programmer in me could not let it lie. Hence I now have the same thing in TCL.

Update 2

See https://chrisgerhard.wordpress.com/2007/08/21/new-wish-and-tickle/

Advertisements

From → homeserver, Solaris

One Comment
  1. Marko permalink

    One thing to note… this script requires full path to file in question or it usually ends up in infinite loop in pathmap function. Not sure how to fix it – something like “if this filename doesn’t start with /, prepend it with `pwd`”.
    It also ends up in infinite loop if “df” command from Sun Companion Software DVD is first in the path (because it outputs a header which isn’t getting parsed out). Easy to fix with changing df to /usr/sbin/df in the script.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: