167 raise Exception('Security check failed, path starts with "/" or "."') |
167 raise Exception('Security check failed, path starts with "/" or "."') |
168 bkup.close() # XXX seek error if not close+open !?! |
168 bkup.close() # XXX seek error if not close+open !?! |
169 bkup = tarfile.open(backupfile, 'r|gz') |
169 bkup = tarfile.open(backupfile, 'r|gz') |
170 tmpdir = tempfile.mkdtemp() |
170 tmpdir = tempfile.mkdtemp() |
171 bkup.extractall(path=tmpdir) |
171 bkup.extractall(path=tmpdir) |
172 if systemonly: |
172 for source in repo.sources: |
173 repo.system_source.restore(osp.join(tmpdir,'system'), drop=drop) |
173 if systemonly and source.uri != 'system': |
174 else: |
174 continue |
175 for source in repo.sources: |
175 try: |
176 try: |
176 source.restore(osp.join(tmpdir, source.uri), drop=drop) |
177 source.restore(osp.join(tmpdir, source.uri), drop=drop) |
177 except Exception, exc: |
178 except Exception, exc: |
178 print '-> error trying to restore [%s]' % exc |
179 print '-> error trying to restore [%s]' % exc |
179 if not self.confirm('Continue anyway?', default='n'): |
180 if not self.confirm('Continue anyway?', default='n'): |
180 raise SystemExit(1) |
181 raise SystemExit(1) |
|
182 bkup.close() |
181 bkup.close() |
183 shutil.rmtree(tmpdir) |
182 shutil.rmtree(tmpdir) |
184 # call hooks |
183 # call hooks |
185 repo.hm.call_hooks('server_restore', repo=repo, timestamp=backupfile) |
184 repo.hm.call_hooks('server_restore', repo=repo, timestamp=backupfile) |
186 print '-> database restored.' |
185 print '-> database restored.' |