diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-22 17:56:35 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-22 17:56:35 +0100 |
commit | 9cabe5253d95dc4b2064653023bcefb342345e40 (patch) | |
tree | a29ca68fd2f8ed624b82870bd227b0eafaab99e0 | |
parent | db13908dadeaa18f70655ac7341c6660e3035d97 (diff) | |
download | obnam-9cabe5253d95dc4b2064653023bcefb342345e40.tar.gz |
Catch errors during a backup, and unlock client if they happen.
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 8bc2548a..e7253111 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -72,16 +72,21 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.add_client(client_name) self.repo.lock_client(client_name) - self.repo.start_generation() - self.fs = None - roots = self.app.settings['root'] + args - if roots: - self.backup_roots(roots) - self.repo.commit_client() - self.repo.fs.close() - - logging.info('Backup finished.') - self.dump_memory_profile('at end of backup run') + try: + self.repo.start_generation() + self.fs = None + roots = self.app.settings['root'] + args + if roots: + self.backup_roots(roots) + self.repo.commit_client() + self.repo.fs.close() + + logging.info('Backup finished.') + self.dump_memory_profile('at end of backup run') + except BaseException: + logging.info('Unlocking client because of error') + self.repo.unlock_client() + raise def add_client(self, client_name): if client_name not in self.repo.list_clients(): |