172 |
172 |
173 def backup_to_file(self, backupfile): |
173 def backup_to_file(self, backupfile): |
174 cmd = self.dbhelper.backup_command(self.dbname, self.dbhost, |
174 cmd = self.dbhelper.backup_command(self.dbname, self.dbhost, |
175 self.dbuser, backupfile, |
175 self.dbuser, backupfile, |
176 keepownership=False) |
176 keepownership=False) |
177 if subprocess.call(cmd): |
177 if subprocess.call(cmd, shell=isinstance(cmd, str)): |
178 raise Exception('Failed command: %s' % cmd) |
178 raise Exception('Failed command: %s' % cmd) |
179 |
179 |
180 def restore_from_file(self, backupfile, confirm, drop=True): |
180 def restore_from_file(self, backupfile, confirm, drop=True): |
181 for cmd in self.dbhelper.restore_commands(self.dbname, self.dbhost, |
181 for cmd in self.dbhelper.restore_commands(self.dbname, self.dbhost, |
182 self.dbuser, backupfile, |
182 self.dbuser, backupfile, |
183 self.encoding, |
183 self.encoding, |
184 keepownership=False, |
184 keepownership=False, |
185 drop=drop): |
185 drop=drop): |
186 if subprocess.call(cmd): |
186 if subprocess.call(cmd, shell=isinstance(cmd, str)): |
187 print '-> Failed command: %s' % cmd |
187 print '-> Failed command: %s' % cmd |
188 if not confirm('Continue anyway?', default='n'): |
188 if not confirm('Continue anyway?', default='n'): |
189 raise Exception('Failed command: %s' % cmd) |
189 raise Exception('Failed command: %s' % cmd) |
190 |
190 |
191 def merge_args(self, args, query_args): |
191 def merge_args(self, args, query_args): |