diff options
author | linimon <linimon@FreeBSD.org> | 2010-05-20 12:07:13 +0800 |
---|---|---|
committer | linimon <linimon@FreeBSD.org> | 2010-05-20 12:07:13 +0800 |
commit | 487300a7850e122c34c429efae9899ff7c0426a8 (patch) | |
tree | 44cbf8b2eacdd48f96d8c68558b07bd28fb2eb2c /Tools | |
parent | db9d64851e23d463dcc0d2e97ce98d8a7e842ef0 (diff) | |
download | freebsd-ports-gnome-487300a7850e122c34c429efae9899ff7c0426a8.tar.gz freebsd-ports-gnome-487300a7850e122c34c429efae9899ff7c0426a8.tar.zst freebsd-ports-gnome-487300a7850e122c34c429efae9899ff7c0426a8.zip |
Trim backup files a bit; make the emails a bit more verbose.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/portbuild/scripts/zbackup | 23 | ||||
-rw-r--r-- | Tools/portbuild/scripts/zexpire | 13 |
2 files changed, 24 insertions, 12 deletions
diff --git a/Tools/portbuild/scripts/zbackup b/Tools/portbuild/scripts/zbackup index 6937980e8e25..19efddd550d8 100755 --- a/Tools/portbuild/scripts/zbackup +++ b/Tools/portbuild/scripts/zbackup @@ -8,7 +8,7 @@ import zfs, commands, datetime, sys, os, bz2 from signal import * # List of filesystems to backup -backuplist=["a", "a/nfs", "a/src", "a/local", "a/ports", "a/portbuild", +backuplist=["a", "a/nfs", "a/local", "a/portbuild", "a/portbuild/amd64", "a/portbuild/i386", "a/portbuild/ia64", "a/portbuild/powerprc", "a/portbuild/sparc64"] @@ -17,7 +17,7 @@ backuplist=["a", "a/nfs", "a/src", "a/local", "a/ports", "a/portbuild", backupdir="/dumpster/pointyhat/backup" # How many days between full backups -fullinterval=3 +fullinterval=9 def validate(): fslist = zfs.getallfs() @@ -48,8 +48,12 @@ class node(object): self.parent = None self.visited = 0 +print "zbackup: starting at " + datetime.datetime.now().ctime() + for fs in backuplist: + print + dir = backupdir + "/" + fs mkdirp(dir) @@ -153,14 +157,14 @@ for fs in backuplist: chain.reverse() - print chain + print "chain is " + str( chain ) # Prune stale links not in the backup chain for j in backups.iterkeys(): cur = backups[j] for k in cur.child: stale="%s-%s" % (cur.name, k.name) - print "Deleting %s" % stale + print "Deleting stale backup %s" % stale os.remove("%s/%s/%s" % (backupdir, fs, stale)) # Lookup date of full dump @@ -186,7 +190,7 @@ for fs in backuplist: # zfs send aborts on receiving a signal signal(SIGTSTP, SIG_IGN) if not dofull: - print "Doing incremental of %s: %s-%s" % (fs, latest, nowdate) + print "Doing incremental backup of %s: %s-%s" % (fs, latest, nowdate) (err, out) = \ commands.getstatusoutput("zfs send -i %s %s@%s | bzip2 > %s" % (latest, fs, nowdate, outfile)) @@ -202,9 +206,9 @@ for fs in backuplist: print "Error from snapshot: (%s, %s)" % (err, out) try: os.remove(outfile) - print "Deleted %s" % outfile + print "Deleted file %s" % outfile except OSError, err: - print repr(err) + print "OSError: " + repr(err) if err.errno != 2: raise finally: @@ -214,10 +218,13 @@ for fs in backuplist: try: os.rename(outfile, "%s/%s/%s-%s" % (backupdir, fs, latest, nowdate)) except: - print "Error renaming dump file!" + print "Error renaming dump file" + outfile + "!" raise if dofull: for i in seen: print "Removing stale snapshot %s/%s" % (dir, i) os.remove("%s/%s" % (dir, i)) + +print +print "zbackup: ending at " + datetime.datetime.now().ctime() diff --git a/Tools/portbuild/scripts/zexpire b/Tools/portbuild/scripts/zexpire index 402edc19071f..22539f899db8 100644 --- a/Tools/portbuild/scripts/zexpire +++ b/Tools/portbuild/scripts/zexpire @@ -7,9 +7,7 @@ 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), @@ -18,7 +16,6 @@ expirelist=(("a", 14), ("a/portbuild/sparc64", 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-8", 7), @@ -27,8 +24,11 @@ expirelist=(("a", 14), ("a/snap/world-i386-HEAD", 7)) now = datetime.datetime.now() +print "zexpire: starting at " + now.ctime() for (fs, maxage) in expirelist: + print + try: snapdata = zfs.getallsnaps(fs) except zfs.NoSuchFS: @@ -44,11 +44,16 @@ for (fs, maxage) in expirelist: try: snapdate = datetime.datetime.strptime(snap, "%Y%m%d%H%M%S") except ValueError: + print "zexpire: don't know what to do with snap `" + snap + "'" continue if (now - snapdate) > datetime.timedelta(days=maxage): - print "Snapshot %s@%s too old" % (fs, snap) + print "Snapshot %s@%s too old, attempting zfs destroy" % (fs, snap) (err, out) = commands.getstatusoutput("zfs destroy %s@%s" % (fs,snap)) if err: print "Error deleting snapshot", out + +then = datetime.datetime.now() +print +print "zexpire: ending at " + then.ctime() |