27 from glob import glob |
27 from glob import glob |
28 from warnings import warn |
28 from warnings import warn |
29 |
29 |
30 from logilab.common.deprecation import deprecated |
30 from logilab.common.deprecation import deprecated |
31 from logilab.common.decorators import cached, clear_cache |
31 from logilab.common.decorators import cached, clear_cache |
32 from logilab.common.adbh import get_adv_func_helper |
|
33 |
32 |
34 from yams.constraints import SizeConstraint |
33 from yams.constraints import SizeConstraint |
35 from yams.schema2sql import eschema2sql, rschema2sql |
34 from yams.schema2sql import eschema2sql, rschema2sql |
36 |
35 |
37 from cubicweb import AuthenticationError, ETYPE_NAME_MAP |
36 from cubicweb import AuthenticationError |
38 from cubicweb.schema import (META_RTYPES, VIRTUAL_RTYPES, |
37 from cubicweb.schema import (META_RTYPES, VIRTUAL_RTYPES, |
39 CubicWebRelationSchema, order_eschemas) |
38 CubicWebRelationSchema, order_eschemas) |
40 from cubicweb.dbapi import get_repository, repo_connect |
39 from cubicweb.dbapi import get_repository, repo_connect |
41 from cubicweb.migration import MigrationHelper, yes |
40 from cubicweb.migration import MigrationHelper, yes |
42 |
41 |
168 def restore_database(self, backupfile, drop=True, systemonly=True, |
167 def restore_database(self, backupfile, drop=True, systemonly=True, |
169 askconfirm=True): |
168 askconfirm=True): |
170 # check |
169 # check |
171 if not osp.exists(backupfile): |
170 if not osp.exists(backupfile): |
172 raise Exception("Backup file %s doesn't exist" % backupfile) |
171 raise Exception("Backup file %s doesn't exist" % backupfile) |
173 return |
|
174 if askconfirm and not self.confirm('Restore %s database from %s ?' |
172 if askconfirm and not self.confirm('Restore %s database from %s ?' |
175 % (self.config.appid, backupfile)): |
173 % (self.config.appid, backupfile)): |
176 return |
174 return |
177 # unpack backup |
175 # unpack backup |
178 tmpdir = tempfile.mkdtemp() |
176 tmpdir = tempfile.mkdtemp() |