summaryrefslogtreecommitdiff
path: root/templates
diff options
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)