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'.
This commit is contained in:
Marek Marczykowski-Górecki 2014-03-17 21:15:39 +01:00
parent b298110d5f
commit 5d7688a2fe
2 changed files with 14 additions and 8 deletions

View File

@ -444,13 +444,16 @@ 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)
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):
if not os.path.exists (os.path.dirname(base_backup_dir)):
raise QubesException(
"ERROR: the backup directory {0} does not exists".
"ERROR: the backup directory for {0} does not exists".
format(base_backup_dir))
# If not APPVM, STDOUT is a local file

View File

@ -107,7 +107,10 @@ def main():
if not options.appvm:
appvm = None
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):