diff options
author | Kris Kennaway <kris@FreeBSD.org> | 2008-07-26 15:06:41 +0000 |
---|---|---|
committer | Kris Kennaway <kris@FreeBSD.org> | 2008-07-26 15:06:41 +0000 |
commit | 4663e0b500fac5b8bc8a79476e2e226162dc76cb (patch) | |
tree | 5a2f86daac6aa8d7b9a6da77b97d2c257a0fa8b9 /Tools | |
parent | 17885ef52d36f463c95936d2d766b065d15aa271 (diff) | |
download | ports-4663e0b500fac5b8bc8a79476e2e226162dc76cb.tar.gz ports-4663e0b500fac5b8bc8a79476e2e226162dc76cb.zip |
Notes
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/portbuild/scripts/zexpire | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Tools/portbuild/scripts/zexpire b/Tools/portbuild/scripts/zexpire new file mode 100644 index 000000000000..8019af0e0d7f --- /dev/null +++ b/Tools/portbuild/scripts/zexpire @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# +# Expire old snapshots + +import zfs, commands, datetime, os + +# List of filesystems to expire +expirelist=(("a", 14), + ("a/nfs", 14), + ("a/src", 14), + ("a/local", 14), + ("a/ports", 14), + ("a/portbuild", 14), + ("a/portbuild/amd64", 14), + ("a/portbuild/i386", 14), + ("a/portbuild/sparc64", 14), + ("a/portbuild/ia64", 14), + ("a/snap", 7), + ("a/snap/ports", 7), + ("a/snap/src-5", 7), + ("a/snap/src-6", 7), + ("a/snap/src-7", 7), + ("a/snap/src-HEAD", 7), + ("a/snap/world-amd64-HEAD", 7), + ("a/snap/world-i386-HEAD", 7)) + +now = datetime.datetime.now() + +for (fs, maxage) in expirelist: + snapdata = zfs.getallsnaps(fs) + snaps = (i[0] for i in snapdata) + + for snap in snaps: + try: + snapdate = datetime.datetime.strptime(snap, "%Y%m%d%H%M") + except ValueError: + try: + snapdate = datetime.datetime.strptime(snap, "%Y%m%d%H%M%S") + except ValueError: + continue + + if (now - snapdate) > datetime.timedelta(days=maxage): + print "Snapshot %s@%s too old" % (fs, snap) + (err, out) = commands.getstatusoutput("zfs destroy %s@%s" % (fs,snap)) + + if err: + print "Error deleting snapshot", out |