Andrew Daugherity
2009-Dec-09 01:23 UTC
[zfs-discuss] my ZFS backup script -- feedback appreciated
After successfully setting up the ZFS auto snapshot package, I was at the point of implementing its backup functionality when I saw the announcement of the removal of that, and the associated uproar. I looked deeper and discovered that the autosnap backup didn''t really meet my needs after all, and couldn''t find anything else out there that did, so I wrote my own script using the zfs send/receive functionality to replicate snapshots to another host. It works as intended, but I''m sure it could be improved. Something I know would be a good change would be converting it to an SMF service, and replacing the lockfile bit with SMF maintenance state, but I don''t know SMF manifests that well, so hopefully someone can contribute one! I also know the error handling could be abstracted out and improved somewhat. I check for the failure cases I can think of and drop to maintenance in case any of those happen. Description/rationale of the script (more detailed comments within the script): # This supplements zfs-auto-snapshot, but runs independently. I prefer that # snapshots continue to be taken even if the backup fails. # # This aims to be much more robust than the backup functionality of # zfs-auto-snapshot, namely: # * it uses ''zfs send -I'' to send all intermediate snapshots (including # any daily/weekly/etc.), and should still work even if it isn''t run # every hour -- as long as the newest remote snapshot hasn''t been # rotated out locally yet # * ''zfs recv -dF'' on the destination host removes any snapshots not # present locally so you don''t have to worry about manually removing # old snapshots there. I realize this doesn''t meet everybody''s needs but hopefully someone will find it useful. Note: I''m running sol10u8. I expect this to work fine on recent OpenSolaris also, but I have not tested that. The only change required to make zfs-auto-snapshot v0.12 work on sol10u8 was changing ksh93 to dtksh in the shebang line. Andrew Daugherity Systems Analyst Division of Research & Graduate Studies Texas A&M University -------------- next part -------------- A non-text attachment was scrubbed... Name: zfs-backup.sh Type: application/x-sh Size: 5120 bytes Desc: not available URL: <http://mail.opensolaris.org/pipermail/zfs-discuss/attachments/20091208/157877d9/attachment.sh>
David Dyer-Bennet
2009-Dec-09 17:51 UTC
[zfs-discuss] my ZFS backup script -- feedback appreciated
On Tue, December 8, 2009 19:23, Andrew Daugherity wrote:> Description/rationale of the script (more detailed comments within the > script): > # This supplements zfs-auto-snapshot, but runs independently. I prefer > that > # snapshots continue to be taken even if the backup fails. > # > # This aims to be much more robust than the backup functionality of > # zfs-auto-snapshot, namely: > # * it uses ''zfs send -I'' to send all intermediate snapshots (including > # any daily/weekly/etc.), and should still work even if it isn''t run > # every hour -- as long as the newest remote snapshot hasn''t been > # rotated out locally yet > # * ''zfs recv -dF'' on the destination host removes any snapshots not > # present locally so you don''t have to worry about manually removing > # old snapshots there. > > I realize this doesn''t meet everybody''s needs but hopefully someone will > find it useful.This description matches pretty well (I''m doing my own snapshots) what I''ve been working on, and having trouble getting to work (getting ZFS errors on one end or the other depending on options). I''m working with OpenSolaris, though, which may make a difference. Dunno when I next get a chance to work on this, maybe this weekend; but having a working example will be great. I''ll either just use yours, or at least benefit from seeing what works; I''ll figure out which when I look more closely. So thanks! -- David Dyer-Bennet, dd-b at dd-b.net; http://dd-b.net/ Snapshots: http://dd-b.net/dd-b/SnapshotAlbum/data/ Photos: http://dd-b.net/photography/gallery/ Dragaera: http://dragaera.info