# HG changeset patch # User Sylvain Thénault # Date 1250859780 -7200 # Node ID 1c6eafc685861c5cb48a396f41e73051c5c98737 # Parent daabb9bc52338e300d349d7475243b1419ec0865 [db-dump] don't create tarball on failed dump, properly remove temporary directory diff -r daabb9bc5233 -r 1c6eafc68586 server/migractions.py --- a/server/migractions.py Fri Aug 21 15:02:03 2009 +0200 +++ b/server/migractions.py Fri Aug 21 15:03:00 2009 +0200 @@ -133,22 +133,27 @@ os.chmod(backupfile, 0600) # backup tmpdir = tempfile.mkdtemp(dir=instbkdir) - for source in repo.sources: - try: - source.backup(osp.join(tmpdir,source.uri)) - except Exception, exc: - print '-> error trying to backup [%s]' % exc - if not self.confirm('Continue anyway?', default='n'): - raise SystemExit(1) - bkup = tarfile.open(backupfile, 'w|gz') - for filename in os.listdir(tmpdir): - bkup.add(osp.join(tmpdir,filename), filename) - bkup.close() - shutil.rmtree(tmpdir) - # call hooks - repo.hm.call_hooks('server_backup', repo=repo, timestamp=timestamp) - # done - print '-> backup file', backupfile + try: + for source in repo.sources: + try: + source.backup(osp.join(tmpdir, source.uri)) + except Exception, exc: + print '-> error trying to backup [%s]' % exc + if not self.confirm('Continue anyway?', default='n'): + raise SystemExit(1) + else: + break + else: + bkup = tarfile.open(backupfile, 'w|gz') + for filename in os.listdir(tmpdir): + bkup.add(osp.join(tmpdir,filename), filename) + bkup.close() + # call hooks + repo.hm.call_hooks('server_backup', repo=repo, timestamp=timestamp) + # done + print '-> backup file', backupfile + finally: + shutil.rmtree(tmpdir) def restore_database(self, backupfile, drop=True, systemonly=True, askconfirm=True):