Hello zfs-discuss, I''m writing a script to do automatically snapshots and destroy old one. I think it would be great to add to zfs destroy another option so only snapshots can be destroyed. Something like: zfs destroy -s SNAPSHOT so if something other than snapshot is provided as an argument zfs destroy wouldn''t actually destroy it. That way it would be much safer to write scripts. What do you think? I can implement it and send diffs - should be really simple. -- Best regards, Robert mailto:rmilkowski at task.gda.pl http://milek.blogspot.com
On Mon, Jun 12, 2006 at 12:58:17PM +0200, Robert Milkowski wrote:> I''m writing a script to do automatically snapshots and destroy old > one. I think it would be great to add to zfs destroy another option > so only snapshots can be destroyed. Something like: > > zfs destroy -s SNAPSHOT > > so if something other than snapshot is provided as an argument > zfs destroy wouldn''t actually destroy it. > That way it would be much safer to write scripts. > > What do you think?I think that you shouldn''t run commands that you don''t want run. If you need some safeguards while developing a script, you can always write a wrapper script around zfs(1m). However, ''zfs destroy <fs>'' will fail if the filesystem has snapshots (presumably most will, if your intent is to destroy a snapshot), which provides you with some safeguards. --matt
On Tue, Jun 13, 2006 at 01:43:08PM -0700, Matthew Ahrens wrote:> On Mon, Jun 12, 2006 at 12:58:17PM +0200, Robert Milkowski wrote: > > I''m writing a script to do automatically snapshots and destroy old > > one. I think it would be great to add to zfs destroy another option > > so only snapshots can be destroyed. Something like: > > > > zfs destroy -s SNAPSHOT > > > > so if something other than snapshot is provided as an argument > > zfs destroy wouldn''t actually destroy it. > > That way it would be much safer to write scripts. > > > > What do you think? > > I think that you shouldn''t run commands that you don''t want run. If you > need some safeguards while developing a script, you can always write a > wrapper script around zfs(1m).Alternatively, you could just make sure your argument always has a ''@'' in it: zfs destroy -s ${fs}@${snapshot} Cheers, - jonathan> However, ''zfs destroy <fs>'' will fail if the filesystem has snapshots > (presumably most will, if your intent is to destroy a snapshot), which > provides you with some safeguards. > > --matt > _______________________________________________ > zfs-discuss mailing list > zfs-discuss at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/zfs-discuss-- Jonathan Adams, Solaris Kernel Development
Hello Matthew, Tuesday, June 13, 2006, 10:43:08 PM, you wrote: MA> On Mon, Jun 12, 2006 at 12:58:17PM +0200, Robert Milkowski wrote:>> I''m writing a script to do automatically snapshots and destroy old >> one. I think it would be great to add to zfs destroy another option >> so only snapshots can be destroyed. Something like: >> >> zfs destroy -s SNAPSHOT >> >> so if something other than snapshot is provided as an argument >> zfs destroy wouldn''t actually destroy it. >> That way it would be much safer to write scripts. >> >> What do you think?MA> I think that you shouldn''t run commands that you don''t want run. If you MA> need some safeguards while developing a script, you can always write a MA> wrapper script around zfs(1m). Well, it''s like saying that we don''t need ''-f'' option for a zpool. It''s just too easy with ZFS to screw up. Using snapshots in ZFS is so easy and penalty free that it''ll be common I belive. Many sysadmins will write their own scripts and it''s just too easy to destroy a filesystem instead of a snapshot unintentionally. I know you can write wrappers, etc. but it just complicates life while simple option would solve problem. The same with ''zpool destroy'' - imho it should never allow destroying a pool if ant fs|clone|snapshot is mounted unless -f is provided. -- Best regards, Robert mailto:rmilkowski at task.gda.pl http://milek.blogspot.com