The musings and important information storage shed of Matt Kulka. I'll write about quirky things about Gentoo, Solaris and probably even Mac OS X or things dealing with systems administration in general as I encounter them at my daily job or in my limited free-time. Yes, even some Apple fanboyism too!

Search

Blog Roll

September 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

XML Feeds

Pruning ZFS snapshots

A while ago, I started doing ZFS backups of some of my remote servers. That is daily rsyncs to a ZFS fs followed by a snapshot creation for that day. After collecting these snapshots for a while, I decided it was time to do some housekeeping and attempted to find a script that would fit my need of keeping everything tidy. In short, I found a few but none were doing things quite the way that I wanted. So I wrote my own in typical sysadmin fashion.

The above link is the script. It may fit your needs. Basically, I wanted to keep X number of daily snapshots, Y number of weekly snapshots and Z number of monthly snapshots. I even through in another slot for yearly backups, just in case. It will evaluate all your snapshots for configured (at the top of the script) filesystems and determine which ones should be kept and which ones should be destroyed. I could've gone ahead and gotten a bit more granular by going down to hourly but that's not how I'm keeping my snapshots now since once-a-day backups are good enough for me. All this script requires you to do is name your snapshots in the YYYYMMDD format, then configure which filesystems to prune and how many of each kind you want to keep.

As with any destructive script, use caution when running it. Running the script with no arguments will generate the help message and give you the possible switches. I highly suggest doing a dry run (-n) to be safe and verbose (-v) to understand what the script is doing, but you will be prompted before snapshot destruction if you run with no arguments. Filesystems and how many snapshots to keep are configured at the top of the script. I may throw in command-line options for that in the future.

Enjoy. Let me know if it works out for you.

UPDATE: darn, posted too soon. Still don't have it quite right. I'll keep working on it.

posted by Matt | 06/05/10 | 06:07:18 pm | 4045 views | Hastily filed in Solaris
PermalinkPermalinkLeave a comment »Send a trackback »

0101010101001010101110101010101011100101010101010100111000111010101011100001010101010101101101010111000110101011001011110101010100101000111010101001110101010101010111101010111011010101001001111011011010011011111010111101001011011101010001110010101010100011110101010101111010101100010010101

Trackback address for this post

Trackback URL (right click and copy shortcut/link location)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

bottom corner