# ZFS automatic snapshots utility



## tanked (Jun 24, 2009)

Hello, I have installed the automatic snapshot utility from /usr/ports/sysutils/zfs-snapshot-mgmt. This utility uses the zfs-snapshot-mgmt.conf file as its configuration and here are the contents of mine:


```
# Automatic ZFS snapshot management configuration file
#
# This is a YAML file (see http://www.yaml.org)
# Use exactly 2 spaces for each indentation level
#
snapshot_prefix: auto-
filesystems:
  tank/data/user:
    # Create snapshots every 24 hours, starting at 20:00.
    creation_rule:
      at_multiple: 1440
      offset: 1300
    # Keep daily snapshots created at 20:00 (in this case all).
    preservation_rules:
      - { for_minutes: 20160, at_multiple: 1440, offset: 1200 }
```

When I run /usr/local/bin/zfs-snapshot-mgmt from cron nothing happens, no snapshots are created. When I manually run it no error message is reported but no snapshot is ceated either.

Any help is appreciated.


----------



## lme@ (Jun 30, 2009)

Can you try it with `# zfs set snapdir=visible <fs>`?


----------



## tanked (Jun 30, 2009)

Thanks for replying, will try your suggestion later when I'm at home.


----------



## hedwards (Jun 30, 2009)

#zfs list
Should show any snapshots made, definitely including the ones that were made via that utility. If you're not seeing them there, then they weren't made.


----------



## tanked (Jun 30, 2009)

lme@ said:
			
		

> Can you try it with `# zfs set snapdir=visible <fs>`?



Unfortunatley it didn't work.


----------



## lme@ (Jun 30, 2009)

This is my working configuration:


```
# Automatic ZFS snapshot management configuration file
#
# This is a YAML file (see http://www.yaml.org)
# Use exactly 2 spaces for each indentation level
#
snapshot_prefix: auto-
filesystems:
  tank/home:
    # Create snapshots recursively for all filesystems mounted under this one
    recursive: true
    # Create snapshots every 10 minutes, starting at midnight
    creation_rule:
      at_multiple: 10
      offset: 0
    # Keep all snapshots for the first 90 minutes,
    # then only those that were created at 30 minute intervals for 12 hours
    # (after snapshot creation),
    # then only those that were created at 3 hour intervals, counting at 2:00
    # (i.e. 2:00, 5:00, 8:00, 11:00, 14:00, 17:00, 20:00, 23:00)
    # for 7 days
    preservation_rules:
      - { for_minutes:    90, at_multiple:    0, offset:    0 }
      - { for_minutes:   720, at_multiple:   30, offset:    0 }
      - { for_minutes: 10080, at_multiple:  180, offset:  120 }
```


----------



## tanked (Jun 30, 2009)

I copied your config and it still didn't work - no error message but no snapshot either.

I used truss to see what the program was doing when I ran it and I have attached the output to this message (see attached .zip file, lots of data). Suffice it to say there are messages like this:


```
stat("/usr/local/lib/ruby/site_ruby/1.8/i386-freebsd7/date/format.rb",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/site_ruby/1.8/i386-freebsd7/date/format.so",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/site_ruby/date/format.rb",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/site_ruby/date/format.so",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/1.8/date/format.rb",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/1.8/date/format.so",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/1.8/i386-freebsd7/date/format.rb",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/1.8/i386-freebsd7/date/format.so",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/date/format.rb",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/vendor_ruby/date/format.so",0xbfbfdb6c) ERR#2 'No such file or directory'
stat("/usr/local/lib/ruby/1.8/date/format.rb
```

but it does seem to access the snapshot directory:


```
open("/data/user/.zfs/snapshot",O_NONBLOCK,05001176626) = 7 (0x7)
fstat(7,{ mode=dr-xr-xr-x ,inode=2,size=2,blksize=4096 }) = 0 (0x0)
```


----------

