diff options
author | Mark Linimon <linimon@FreeBSD.org> | 2010-05-20 04:07:13 +0000 |
---|---|---|
committer | Mark Linimon <linimon@FreeBSD.org> | 2010-05-20 04:07:13 +0000 |
commit | 4a1e5c660e90724d9f8ca6d649653fdcb47c4fe8 (patch) | |
tree | c217e14a796f59105c64b77f297409970ed44520 /Tools | |
parent | b5b4dafb6f15063d446d9b4103e9df7517857599 (diff) | |
download | ports-4a1e5c660e90724d9f8ca6d649653fdcb47c4fe8.tar.gz ports-4a1e5c660e90724d9f8ca6d649653fdcb47c4fe8.zip |
Notes
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() |