From 5d7688a2fec21e3c27e62b00b8d60bcd8e773832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 17 Mar 2014 21:15:39 +0100 Subject: [PATCH] backups: allow provide full path for the backup (instead of directory) (#801) This will allow the user to choose custom filename, instead of auto generated 'qubes-backup-XXX'. --- core/backup.py | 17 ++++++++++------- qvm-tools/qvm-backup | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/backup.py b/core/backup.py index 98ccd0ee..52154a2d 100644 --- a/core/backup.py +++ b/core/backup.py @@ -444,14 +444,17 @@ def backup_do(base_backup_dir, files_to_backup, passphrase, running_backup_operation.processes_to_kill_on_cancel.append(vmproc) else: # Prepare the backup target (local file) - backup_target = base_backup_dir + "/qubes-{0}". \ - format(time.strftime("%Y-%m-%dT%H%M%S")) + if os.path.isdir(base_backup_dir): + backup_target = base_backup_dir + "/qubes-{0}". \ + format(time.strftime("%Y-%m-%dT%H%M%S")) + else: + backup_target = base_backup_dir - # Create the target directory - if not os.path.exists (base_backup_dir): - raise QubesException( - "ERROR: the backup directory {0} does not exists". - format(base_backup_dir)) + # Create the target directory + if not os.path.exists (os.path.dirname(base_backup_dir)): + raise QubesException( + "ERROR: the backup directory for {0} does not exists". + format(base_backup_dir)) # If not APPVM, STDOUT is a local file backup_stdout = open(backup_target,'wb') diff --git a/qvm-tools/qvm-backup b/qvm-tools/qvm-backup index 73137ae8..60d70f24 100755 --- a/qvm-tools/qvm-backup +++ b/qvm-tools/qvm-backup @@ -107,7 +107,10 @@ def main(): if not options.appvm: appvm = None - stat = os.statvfs(base_backup_dir) + if os.path.isdir(base_backup_dir): + stat = os.statvfs(base_backup_dir) + else: + stat = os.statvfs(os.path.dirname(base_backup_dir)) backup_fs_free_sz = stat.f_bsize * stat.f_bavail print if (total_backup_sz > backup_fs_free_sz):