diff options
| author | Curtis Hovey <curtis@canonical.com> | 2013-04-25 11:58:45 -0400 |
|---|---|---|
| committer | Curtis Hovey <curtis@canonical.com> | 2013-04-25 11:58:45 -0400 |
| commit | be2eab306a35435f7510940452842703ba76030c (patch) | |
| tree | 07d3b30a0ddbdc54776cbb9730d27198c320c332 | |
| parent | 7a798aef42dd7d4ab6f2d0d08ae26841ad73309f (diff) | |
Ensure the backupdir exists before listing it.
| -rw-r--r-- | revision | 2 | ||||
| -rwxr-xr-x | templates/backup.py.tpl | 16 |
2 files changed, 9 insertions, 9 deletions
@@ -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" % ( |
