Page 1 of 1

Snapshots in Time Machine-style

Posted: 03 Dec 2012 09:10
by ku-gew
I would like to set up a N4F machine and I would like to take regular snapshots of its content. Being used to Time Machine under Mac, I would like to keep old snapshots using the same rules: one per hour in the last day, one per day for the last week, one per week for the past year, one per month after that time.
Is this possible? This would be a useful improvement over the interface I saw in the WebGUI, where this kind of snapshots can maybe be set manually, but not easily.

Re: Snapshots in Time Machine-style

Posted: 12 Dec 2012 14:23
by fsbruva
The best thing I have found is zfs_snap, available on git-hub aXon github.

First: You need set the com.sun:auto-snapshot property for all datasets you'd like to snapshot. In this way, you can specify which datasets are protected, and which are not. The property has no usage outside of this snapshot script, so don't worry. Additionally, the script snapshots and destroys snapshots recursively. This is done via the commandline, e.g.:

Code: Select all

zfs set com.sun:auto-snapshot= true zpool/music
zfs set com.sun:auto-snapshot= true zpool/movies
zfs set com.sun:auto-snapshot= true zpool/pictures
1. Create script someplace non-volatile (my scripts are in a folder on my zfs pool)
2. Put the contents of the above shell script into a new file (being mindful of extra newlines if you use nano)
3. ADDING "exit 0" after the last line <---- VERY IMPORTANT
3. Save the script
4. Make the script executable
5. Create your cron jobs using System --> Advanced --> cron

It seems like you would want to create:
Hourly task that runs: bash /mnt/zpool/folder/ -d hourly -r 24
Daily task that runs: bash /mnt/zpool/folder/ -d daily -r 7
Weekly task that runs: bash /mnt/zpool/folder/ -d weekly -r 52
Monthly task that runs: bash /mnt/zpool/folder/ -d monthly -r (insert the total number of months you want to keep)

It would be good to test each of these cron jobs to ensure they run properly. Keep in mind, your first monthly snapshot you take (as it is the longest term) will persist and continue to grow until it has expired, so it is imperative that you do that today so you can always get back to today. Also, monitor the size of your snapshots, and you can adjust how many you keep accordingly, or send the snapshots for long-term backup.

I have: hourly keep 24, daily keep 7, weekly keep 5, monthly keep 12, yearly keep 10.

Re: Snapshots in Time Machine-style

Posted: 12 Dec 2012 15:57
by ku-gew
Thank, I will try it!

You may also check this one:

Duplication of efforts :(

Re: Snapshots in Time Machine-style

Posted: 02 Jan 2013 15:21
by fritz
Another option:

You can use the scripts I provided to the nas4free community here: