summaryrefslogtreecommitdiff
path: root/templates
diff options
authorjrwren@xmtp.net <>2016-07-20 17:40:34 -0400
committerjrwren@xmtp.net <>2016-07-20 17:40:34 -0400
commitf4329a97b94813ef9bcf465b0887974ce8ac8183 (patch)
tree7a0f2a8b074ce4747557f14a06cc36f534982bae /templates
parent0b7b328a92c521d6115019b1ea02108cd7ca4ecb (diff)
fix backup from crash and fail
When files or dirs cannot be removed, warn and continue. Fix mongodbump typos.
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/backup.py.tpl12
1 files changed, 10 insertions, 2 deletions
diff --git a/templates/backup.py.tpl b/templates/backup.py.tpl
index 024520d..dc461b2 100755
--- a/templates/backup.py.tpl
+++ b/templates/backup.py.tpl
@@ -1,6 +1,7 @@
#!/usr/bin/env python
-"""Generate the cronjob to backup with mongodbump."""
+"""Generate the cronjob to backup with mongodump."""
+import logging
from os import chdir
from os import listdir
from os import remove
@@ -11,6 +12,9 @@ from shutil import rmtree
import subprocess
from tempfile import mkdtemp
+logging.basicConfig()
+# use backup.py as logger name because __name__ will be __main__
+logger = logging.getLogger('backup.py')
when = datetime.now()
backupdir = '$backup_directory'
@@ -28,7 +32,11 @@ if not exists(backupdir):
current_backups = listdir(backupdir)
current_backups.sort()
for file in current_backups[0:-$backup_copies]:
- remove(join(backupdir, file))
+ fname = join(backupdir, file)
+ try:
+ remove(fname)
+ except Exception as e:
+ logger.warning("could not remove %s:%s", fname, e)
chdir(tmpdir)