backup: check for disk space if target is local directory
This commit is contained in:
parent
51f119326b
commit
e7701d9c5d
@ -964,19 +964,10 @@ def backup_prepare(base_backup_dir, vms_list = None, exclude_list = [], print_ca
|
|||||||
fmt="{{0:-^{0}}}-+".format(f["width"] + 1)
|
fmt="{{0:-^{0}}}-+".format(f["width"] + 1)
|
||||||
s += fmt.format('-')
|
s += fmt.format('-')
|
||||||
print_callback(s)
|
print_callback(s)
|
||||||
# TODO: check at least if backing up to local drive
|
|
||||||
'''
|
|
||||||
stat = os.statvfs(base_backup_dir)
|
|
||||||
backup_fs_free_sz = stat.f_bsize * stat.f_bavail
|
|
||||||
print_callback("")
|
|
||||||
if (total_backup_sz > backup_fs_free_sz):
|
|
||||||
raise QubesException("Not enough space available on the backup filesystem!")
|
|
||||||
|
|
||||||
if (there_are_running_vms):
|
if (there_are_running_vms):
|
||||||
raise QubesException("Please shutdown all VMs before proceeding.")
|
raise QubesException("Please shutdown all VMs before proceeding.")
|
||||||
|
|
||||||
print_callback("-> Available space: {0}".format(size_to_human(backup_fs_free_sz)))
|
|
||||||
'''
|
|
||||||
return files_to_backup
|
return files_to_backup
|
||||||
|
|
||||||
def backup_do(base_backup_dir, files_to_backup, progress_callback = None):
|
def backup_do(base_backup_dir, files_to_backup, progress_callback = None):
|
||||||
|
@ -75,6 +75,19 @@ def main():
|
|||||||
print >>sys.stderr, "ERROR: %s" % str(e)
|
print >>sys.stderr, "ERROR: %s" % str(e)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
total_backup_sz = reduce(lambda size, file: size+file["size"],
|
||||||
|
files_to_backup, 0)
|
||||||
|
|
||||||
|
if not options.appvm:
|
||||||
|
stat = os.statvfs(base_backup_dir)
|
||||||
|
backup_fs_free_sz = stat.f_bsize * stat.f_bavail
|
||||||
|
print
|
||||||
|
if (total_backup_sz > backup_fs_free_sz):
|
||||||
|
print >>sys.stderr, "ERROR: Not enough space available on the backup filesystem!"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
print "-> Available space: {0}".format(size_to_human(backup_fs_free_sz))
|
||||||
|
|
||||||
prompt = raw_input ("Do you want to proceed? [y/N] ")
|
prompt = raw_input ("Do you want to proceed? [y/N] ")
|
||||||
if not (prompt == "y" or prompt == "Y"):
|
if not (prompt == "y" or prompt == "Y"):
|
||||||
exit (0)
|
exit (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user