mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add a --dry-run option to backup_create that returns the size of items that will be backed up
This commit is contained in:
parent
81c43747a0
commit
28268c58eb
3 changed files with 12 additions and 1 deletions
|
@ -890,6 +890,9 @@ backup:
|
||||||
--apps:
|
--apps:
|
||||||
help: List of application names to backup (or all if none given)
|
help: List of application names to backup (or all if none given)
|
||||||
nargs: "*"
|
nargs: "*"
|
||||||
|
--dry-run:
|
||||||
|
help: "'Simulate' the backup and return the size details per item to backup"
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### backup_restore()
|
### backup_restore()
|
||||||
restore:
|
restore:
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
"backup_copying_to_organize_the_archive": "Copying {size:s}MB to organize the archive",
|
"backup_copying_to_organize_the_archive": "Copying {size:s}MB to organize the archive",
|
||||||
"backup_couldnt_bind": "Could not bind {src:s} to {dest:s}.",
|
"backup_couldnt_bind": "Could not bind {src:s} to {dest:s}.",
|
||||||
"backup_created": "Backup created",
|
"backup_created": "Backup created",
|
||||||
|
"backup_create_size_estimation": "The archive will contain about {size} of data.",
|
||||||
"backup_creation_failed": "Could not create the backup archive",
|
"backup_creation_failed": "Could not create the backup archive",
|
||||||
"backup_csv_addition_failed": "Could not add files to backup into the CSV file",
|
"backup_csv_addition_failed": "Could not add files to backup into the CSV file",
|
||||||
"backup_csv_creation_failed": "Could not create the CSV file needed for restoration",
|
"backup_csv_creation_failed": "Could not create the CSV file needed for restoration",
|
||||||
|
|
|
@ -2138,7 +2138,7 @@ class CustomBackupMethod(BackupMethod):
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
def backup_create(
|
def backup_create(
|
||||||
operation_logger,
|
operation_logger,
|
||||||
name=None, description=None, methods=[], output_directory=None, system=[], apps=[]
|
name=None, description=None, methods=[], output_directory=None, system=[], apps=[], dry_run=False
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create a backup local archive
|
Create a backup local archive
|
||||||
|
@ -2220,8 +2220,15 @@ def backup_create(
|
||||||
# Collect files to be backup (by calling app backup script / system hooks)
|
# Collect files to be backup (by calling app backup script / system hooks)
|
||||||
backup_manager.collect_files()
|
backup_manager.collect_files()
|
||||||
|
|
||||||
|
if dry_run:
|
||||||
|
return {
|
||||||
|
"size": backup_manager.size,
|
||||||
|
"size_details": backup_manager.size_details
|
||||||
|
}
|
||||||
|
|
||||||
# Apply backup methods on prepared files
|
# Apply backup methods on prepared files
|
||||||
logger.info(m18n.n("backup_actually_backuping"))
|
logger.info(m18n.n("backup_actually_backuping"))
|
||||||
|
logger.info(m18n.n("backup_create_size_estimation", size=binary_to_human(backup_manager.size) + "B"))
|
||||||
backup_manager.backup()
|
backup_manager.backup()
|
||||||
|
|
||||||
logger.success(m18n.n("backup_created"))
|
logger.success(m18n.n("backup_created"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue