]> andersk Git - sql.git/commitdiff
fix daily_afs_backup
authorJoe Presbrey <presbrey@mit.edu>
Sun, 21 Mar 2010 06:28:49 +0000 (06:28 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Sun, 21 Mar 2010 06:28:49 +0000 (06:28 +0000)
git-svn-id: svn://presbrey.mit.edu/sql@183 a142d4bd-2cfb-0310-9673-cb33a7e74f58

libexec/daily_afs_backups

index ecdadfdd7760c35741bf40a1a0379a493dcf607c..784a5798b1aab2fe19ea13cbad3587dd01b4c07a 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/python
 
 import os, sys, time
-from sql import db
-from sql.util import new_cursor, get_dbs, db_backup_pre, db_backup_mkdir
+from mitsql import db
+from mitsql.util import new_cursor, get_dbs, db_backup_pre, db_backup_mkdir
 from Queue import Queue, Empty
 import threading
 import subprocess
@@ -29,10 +29,14 @@ def consumer():
             db_backup_mkdir(next[1])
             args = ['mysqldump', next[0]]
             args.extend(MYSQLDUMP_ARGS)
-            p0 = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-            p1 = subprocess.Popen(['gzip'], stdin=p0.stdout, stdout=file(next[1], 'w+'))
-            p1.wait()
-            err = p0.stderr.read()
+            err = ''
+            try:
+                p0 = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                p1 = subprocess.Popen(['gzip'], stdin=p0.stdout, stdout=file(next[1], 'w+'))
+                p1.wait()
+                err = p0.stderr.read()
+            except Exception, e:
+                err = str(e)
             if len(err):
                 log.dump_errnum = p0.returncode
                 log.dump_errstr = err
@@ -53,17 +57,17 @@ t_consumer.start()
 
 def producer():
     c = new_cursor('mysqldump')
-    for db in get_dbs(c):
-        log = db.Backup.get_by(db=db)
+    for dbname in get_dbs(c):
+        log = db.Backup.get_by(db=dbname)
         if not log:
-            log = db.Backup(db=db)
+            log = db.Backup(db=dbname)
         elif log.skip_date and log.skip_date.timetuple:
             if time.mktime(log.skip_date.timetuple()) + 3600 > time.time():
                 # never recheck a db skipped in the past hour
                 continue
-        d = db_backup_pre(c, db)
+        d = db_backup_pre(c, dbname)
         if d[0]:
-            queue.put((db, d[1]))
+            queue.put((dbname, d[1]))
             log.skip_reason = None
             log.skip_date = None
         else:
This page took 0.266187 seconds and 5 git commands to generate.