From be2eab306a35435f7510940452842703ba76030c Mon Sep 17 00:00:00 2001 From: Curtis Hovey Date: Thu, 25 Apr 2013 11:58:45 -0400 Subject: Ensure the backupdir exists before listing it. --- revision | 2 +- templates/backup.py.tpl | 16 ++++++++-------- 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" % ( -- cgit v1.2.3