[db backup] fix name error in backup_to_file: we've to pass .confirm all along the chain as for restore stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 12 Mar 2010 14:55:41 +0100
branchstable
changeset 4893 15ae9a33a7f2
parent 4892 7ee8f128be9e
child 4898 5dec0d400d08
[db backup] fix name error in backup_to_file: we've to pass .confirm all along the chain as for restore
server/migractions.py
server/sources/extlite.py
server/sources/native.py
server/sqlutils.py
--- a/server/migractions.py	Fri Mar 12 14:52:22 2010 +0100
+++ b/server/migractions.py	Fri Mar 12 14:55:41 2010 +0100
@@ -145,9 +145,9 @@
         try:
             for source in repo.sources:
                 try:
-                    source.backup(osp.join(tmpdir, source.uri))
-                except Exception, exc:
-                    print '-> error trying to backup %s [%s]' % (source.uri, exc)
+                    source.backup(osp.join(tmpdir, source.uri, self.confirm))
+                except Exception, ex:
+                    print '-> error trying to backup %s [%s]' % (source.uri, ex)
                     if not self.confirm('Continue anyway?', default='n'):
                         raise SystemExit(1)
                     else:
@@ -187,7 +187,6 @@
             bkup = tarfile.open(backupfile, 'r|gz')
             bkup.extractall(path=tmpdir)
             bkup.close()
-
         self.config.open_connections_pools = False
         repo = self.repo_connect()
         for source in repo.sources:
--- a/server/sources/extlite.py	Fri Mar 12 14:52:22 2010 +0100
+++ b/server/sources/extlite.py	Fri Mar 12 14:55:41 2010 +0100
@@ -93,11 +93,11 @@
         AbstractSource.__init__(self, repo, appschema, source_config,
                                 *args, **kwargs)
 
-    def backup(self, backupfile):
+    def backup(self, backupfile, confirm):
         """method called to create a backup of the source's data"""
         self.close_pool_connections()
         try:
-            self.sqladapter.backup_to_file(backupfile)
+            self.sqladapter.backup_to_file(backupfile, confirm)
         finally:
             self.open_pool_connections()
 
--- a/server/sources/native.py	Fri Mar 12 14:52:22 2010 +0100
+++ b/server/sources/native.py	Fri Mar 12 14:55:41 2010 +0100
@@ -13,7 +13,7 @@
 """
 __docformat__ = "restructuredtext en"
 
-from threading import Lock
+from o_threading import Lock
 from datetime import datetime
 from base64 import b64decode, b64encode
 
@@ -216,11 +216,11 @@
         pool.pool_reset()
         self.repo._free_pool(pool)
 
-    def backup(self, backupfile):
+    def backup(self, backupfile, confirm):
         """method called to create a backup of the source's data"""
         self.close_pool_connections()
         try:
-            self.backup_to_file(backupfile)
+            self.backup_to_file(backupfile, confirm)
         finally:
             self.open_pool_connections()
 
--- a/server/sqlutils.py	Fri Mar 12 14:52:22 2010 +0100
+++ b/server/sqlutils.py	Fri Mar 12 14:55:41 2010 +0100
@@ -172,7 +172,7 @@
         #self.dbapi_module.type_code_test(cnx.cursor())
         return cnx
 
-    def backup_to_file(self, backupfile):
+    def backup_to_file(self, backupfile, confirm):
         for cmd in self.dbhelper.backup_commands(backupfile=backupfile,
                                                  keepownership=False,
                                                  dbname=self.dbname,