From 326439a4d1e90b085aee8b2a6eef4536c1dbd545 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 16 Apr 2020 14:09:21 +0530 Subject: [PATCH] fix: backups dont break if one site is corrupted --- frappe/commands/site.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index fd43cc8cf3..b88e9f78c0 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -317,10 +317,18 @@ def backup(context, with_files=False, backup_path_db=None, backup_path_files=Non "Backup" from frappe.utils.backups import scheduled_backup verbose = context.verbose + exit_code = 0 for site in context.sites: - 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) + 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) + except Exception as e: + if verbose: + print("Backup failed for {0}. Database or site_config.json may be corrupted".format(site)) + exit_code = 1 + continue + if verbose: from frappe.utils import now print("database backup taken -", odb.backup_path_db, "- on", now()) @@ -329,6 +337,7 @@ def backup(context, with_files=False, backup_path_db=None, backup_path_files=Non print("private files backup taken -", odb.backup_path_private_files, "- on", now()) frappe.destroy() + sys.exit(exit_code) @click.command('remove-from-installed-apps') @click.argument('app')