btrsnap README
Sean Reifschneider
Nov  1 18:20:27 MDT 2010
========================

btrsnap is a simple program that is meant to be called from crontab on a
btrfs system to take regular snapshots and expire old ones.  btrfs allows
for creation of light-weight snapshots.  Have you ever wanted to retrieve a
copy of a file or your browser bookmarks or the list of files in a
directory 5 minutes ago?  Or an hour ago, or any period more recent than a
daily backup?  btrsnap helps with creating and expiring snapshots.

WARNING: Keeping these snapshots can mean that removal of files probably
   won't show up in "df" (or as free space at all) until either you
   manually remove the snapshots that continue to hold on to those
   otherwise removed files, or those snapshots expire.  So if you
   accidentally fill up your disc, you may have to surgically remove
   snapshots.  If you remove a bunch of files "df" probably won't show
   it until all your snapshot copies expire (say, a day later)...

WARNING: You probably want to exclude your snapshot directory from being
   walked by updatedb.  I ended up with a 800MB updatedb because of this,
   instead of the normal 20MB.  You should add it to the "PRUNEPATHS" line
   in "/etc/updatedb.conf" .

The usage is:

   usage: btrsnap <prefix> <keep> <source_dir> <snapshot_dir>

      prefix: backup name prefix, for example "1h" or "5m".
      keep: Number of copies of this to keep.
      source_dir: btrfs file-system mount-point to snapshot.
      snapshot_dir: Directory to put snapshots in.

For example, a simple /etc/crontab entry may be:

   0 * * * * root /usr/sbin/btrsnap 1h 24 / /.snapshots
   5-55/5 * * * * root /usr/sbin/btrsnap 5m 22 / /.snapshots

Note: this has "root" in it as the user to run as, you will need to remove
this if you place it in the normal crontab (via "crontab -e", for example.

The above example takes a snapshot every hour, with the name "1h" and keeps
24 of these around.  The "/" file-system is snapshotted to the "/.snapshots"
directory.  It also runs every 5 minutes between 5 and 55 minutes after the
hour, and saves 22 of them.  Note that "5m" and "1h" are just labels, it is
cron that specifies how often the snapshots are taken.  You could just as
easily use the label "hourly" or "george" if you prefer, they don't mean
anything to btrsnap.

After running for around an hour, you may have something like this as the
results:

   guin:Documents$ ls -1 /.snapshots/
   1h-20101101-170001/
   1h-20101101-180001/
   5m-20101101-170501/
   5m-20101101-171002/
   5m-20101101-171501/
   5m-20101101-172001/
   5m-20101101-172501/
   5m-20101101-173001/
   5m-20101101-173501/
   5m-20101101-174001/
   5m-20101101-174501/
   5m-20101101-175001/
   5m-20101101-175501/
   5m-20101101-180501/
   5m-20101101-181001/
   5m-20101101-181501/
   5m-20101101-182001/
   guin:Documents$ 
