14

I accidentally delete some files from my zfs pool and tried to mount the latest snapshots but i just figured out that i have no snapshots. How to activate the snapshots, how to configure it?

I am using Ubuntu 12.04.1 server and zfs 0.6.1, pool version is 28.

2 Answers 2

27

Starting from Ubuntu 17.04 you can install zfs-auto-snapshot like this:

sudo apt install zfs-auto-snapshot

For Ubuntu versions prior 17.04 you could setup zfs-auto-snapshot to use automatic snapshots from repository

sudo add-apt-repository ppa:zfs-native/stable; sudo apt-get install zfs-auto-snapshot

or directly from github

curl -L https://github.com/zfsonlinux/zfs-auto-snapshot/archive/master.tar.gz | tar xz -C /tmp/
pushd /tmp/zfs-auto-snapshot-master && sudo make install && popd && rm -rf /tmp/zfs-auto-snapshot-master

By default it creates snapshots for each data set every 15 minutes and saves snapshot up to 1 year. However you could disable snapshots for specific dataset by setting com.sun:auto-snapshot dataset property to false

sudo zfs set com.sun:auto-snapshot=false tank/tmp

You could also use com.sun:auto-snapshot:... properties to tune auto snapshot behaviour. E.g. save snapshots daily for 31 days for tank/backup dataset:

sudo zfs set com.sun:auto-snapshot=true tank/backup
sudo zfs set com.sun:auto-snapshot:monthly=false tank/backup
sudo zfs set com.sun:auto-snapshot:weekly=false tank/backup
sudo zfs set com.sun:auto-snapshot:daily=true tank/backup
sudo zfs set com.sun:auto-snapshot:hourly=false tank/backup
sudo zfs set com.sun:auto-snapshot:frequent=false tank/backup

By default script saves:

  • frequent snapshots every 15 mins, keeping 4 snapshots
  • hourly snapshots every hour, keeping 24 snapshots
  • daily snapshots every day, keeping 31 snapshots
  • weekly snapshots every week, keeping 7 snapshots
  • monthly snapshots every month, keeping 12 snapshots
4
  • 2
    You can also install using the prepackaged ZFS repo: sudo add-apt-repository ppa:zfs-native/stable; sudo apt-get install zfs-auto-snapshot
    – ScottJ
    Jun 1, 2014 at 2:27
  • Thank you Scott! I've added information about repository to the answer.
    – Andrey
    Jun 1, 2014 at 13:52
  • The PPA is only available for trusty.
    – Bram Geron
    Aug 6, 2017 at 20:56
  • Now in 2021 , zfs-auto-snapshot is in the main repo, no extra work required.
    – sig
    Jun 6, 2021 at 8:41
4

If you have not taken any snapshots, you lost your data.

To take snapshot, use zfs snapshot command

http://docs.oracle.com/cd/E19253-01/819-5461/gbcya/index.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .