From: Joe Presbrey Date: Tue, 4 Oct 2011 02:07:10 +0000 (+0000) Subject: backups: keep less monthlys X-Git-Url: http://andersk.mit.edu/gitweb/sql.git/commitdiff_plain/HEAD backups: keep less monthlys git-svn-id: svn://presbrey.mit.edu/sql@186 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- diff --git a/libexec/backup-policy.py b/libexec/backup-policy.py index a05415c..85c55cf 100755 --- a/libexec/backup-policy.py +++ b/libexec/backup-policy.py @@ -11,14 +11,14 @@ backups.reverse() backups = [[x, re.match('.*(\d\d\d\d-\d\d-\d\d).*', x)] for x in backups] backups = [[x[0], strptime(x[1].groups()[0], '%Y-%m-%d')] for x in backups] -keep = backups[:3] -backups = backups[3:] +keep = backups[:2] +backups = backups[2:] monthlys = {} for x in backups: month = (x[1].tm_year, x[1].tm_mon) if month not in monthlys: monthlys[month] = x - if len(monthlys) > 4: + if len(monthlys) > 3: break keep.extend(monthlys.values()) diff --git a/libexec/daily_afs_backups b/libexec/daily_afs_backups index 784a579..c7c6288 100755 --- a/libexec/daily_afs_backups +++ b/libexec/daily_afs_backups @@ -20,6 +20,7 @@ def consumer(): while True: try: next = queue.get(timeout=3) + print "Consuming", next #print next[0] + ':', log = db.Backup.get_by(db=next[0]) if not log: @@ -36,6 +37,8 @@ def consumer(): p1.wait() err = p0.stderr.read() except Exception, e: + print "Error on", next + print e err = str(e) if len(err): log.dump_errnum = p0.returncode @@ -47,9 +50,12 @@ def consumer(): db.session.flush() #print 'Done' except (KeyboardInterrupt, SystemExit): + print "Got exit request" break except Empty: + print "No queue." if finished: + print "Done!" break t_consumer = threading.Thread(target=consumer)