From bf6baff2e40e7cc4276e2dda30728b79cf353dea Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 1 Sep 2020 20:16:07 +0530 Subject: [PATCH] fix: Pass conf path via backup command --- frappe/commands/site.py | 4 ++-- frappe/utils/backups.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 40149582cb..1138021f80 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -392,7 +392,7 @@ def use(site, sites_path='.'): @click.option('--verbose', default=False, is_flag=True) @pass_context def backup(context, with_files=False, backup_path_db=None, backup_path_files=None, - backup_path_private_files=None, quiet=False, verbose=False, compress=False): + backup_path_private_files=None, backup_path_conf=None, quiet=False, verbose=False, compress=False): "Backup" from frappe.utils.backups import scheduled_backup verbose = verbose or context.verbose @@ -401,7 +401,7 @@ def backup(context, with_files=False, backup_path_db=None, backup_path_files=Non try: frappe.init(site=site) frappe.connect() - odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, force=True, verbose=verbose, compress=compress) + odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, backup_path_conf=backup_path_conf, force=True, verbose=verbose, compress=compress) except Exception as e: if verbose: print("Backup failed for {0}. Database or site_config.json may be corrupted".format(site)) diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index 6e039443a6..c530fc441a 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -281,19 +281,21 @@ def fetch_latest_backups(): } -def scheduled_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, force=False, verbose=False, compress=False): +def scheduled_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, backup_path_conf=None, force=False, verbose=False, compress=False): """this function is called from scheduler deletes backups older than 7 days takes backup""" - odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=force, verbose=verbose, compress=compress) + odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, backup_path_conf=backup_path_conf, force=force, verbose=verbose, compress=compress) return odb -def new_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, force=False, verbose=False, compress=False): +def new_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, backup_path_conf=None, force=False, verbose=False, compress=False): delete_temp_backups(older_than = frappe.conf.keep_backups_for_hours or 24) odb = BackupGenerator(frappe.conf.db_name, frappe.conf.db_name,\ frappe.conf.db_password, - backup_path_db=backup_path_db, backup_path_files=backup_path_files, + backup_path_db=backup_path_db, + backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, + backup_path_conf=backup_path_conf, db_host = frappe.db.host, db_port = frappe.db.port, db_type = frappe.conf.db_type, @@ -343,9 +345,9 @@ def get_backup_path(): backup_path = frappe.utils.get_site_path(conf.get("backup_path", "private/backups")) return backup_path -def backup(with_files=False, backup_path_db=None, backup_path_files=None, quiet=False): +def backup(with_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, backup_path_conf=None, quiet=False): "Backup" - odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=True) + odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, backup_path_conf=backup_path_conf, force=True) return { "backup_path_db": odb.backup_path_db, "backup_path_files": odb.backup_path_files,