summaryrefslogtreecommitdiff
diff options
authorCurtis Hovey <curtis@canonical.com>2013-04-25 11:58:45 -0400
committerCurtis Hovey <curtis@canonical.com>2013-04-25 11:58:45 -0400
commitbe2eab306a35435f7510940452842703ba76030c (patch)
tree07d3b30a0ddbdc54776cbb9730d27198c320c332
parent7a798aef42dd7d4ab6f2d0d08ae26841ad73309f (diff)
Ensure the backupdir exists before listing it.
-rw-r--r--revision2
-rwxr-xr-xtemplates/backup.py.tpl16
2 files changed, 9 insertions, 9 deletions
diff --git a/revision b/revision
index 6f4247a..f64f5d8 100644
--- a/revision
+++ b/revision
@@ -1 +1 @@
-26
+27
diff --git a/templates/backup.py.tpl b/templates/backup.py.tpl
index bb1f079..024520d 100755
--- a/templates/backup.py.tpl
+++ b/templates/backup.py.tpl
@@ -16,14 +16,6 @@ when = datetime.now()
backupdir = '$backup_directory'
tmpdir = mkdtemp()
-# Clean up any old backup copies.
-current_backups = listdir(backupdir)
-current_backups.sort()
-for file in current_backups[0:-$backup_copies]:
- remove(join(backupdir, file))
-
-chdir(tmpdir)
-
# Make sure the directory to stick tarballs exist.
if not exists(backupdir):
subprocess.call([
@@ -32,6 +24,14 @@ if not exists(backupdir):
backupdir,
])
+# Clean up any old backup copies.
+current_backups = listdir(backupdir)
+current_backups.sort()
+for file in current_backups[0:-$backup_copies]:
+ remove(join(backupdir, file))
+
+chdir(tmpdir)
+
# Generate a pretty unique backup filename.
# The unique name might have slashes in it so replace them.
backup_filename = "%s/%s-%s.tar.gz" % (