Repository: frappe/frappe

Issue:
Bench update not working
Hi 

Currently when doing bench update (develop branch) it just drops after "Backing up sites..." 

bench version is 5.0.0
ERPnext & Frappe are in develop


Discussion:
Traceback screenshots?
hi @gavindsouza 

its not much of a traceback

![image](https://user-images.githubusercontent.com/1904802/82431783-28500880-9aa0-11ea-9064-b4dea6d42c2f.png)

bench build 
bench migrate 
works separately

but any commands with bench update drops after Backing up sites as seen in screenshot


Seems like there was some issue with running frappe commands via bench. As a workaround you can backup sites manually first with `bench --sit all backup` and then run `bench update --no-backup`
Caused by https://github.com/frappe/frappe/commit/d3f8a5bbb9fe49c22e363c76dac155fe30ba4f5a

Resolving patch:
diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py
--- a/frappe/utils/backups.py
+++ b/frappe/utils/backups.py
@@ -3,18 +3,18 @@
 
 """This module handles the On Demand Backup utility"""
 
-from __future__ import unicode_literals, print_function
+from __future__ import print_function, unicode_literals
 
-#Imports
-from frappe import _
-import os, frappe
+import os
 from datetime import datetime
+
+import frappe
+from frappe import _, conf
 from frappe.utils import cstr, get_url, now_datetime
 
-#Global constants
-verbose = 0
-from frappe import conf
-#-------------------------------------------------------------------------------
+_verbose = False
+
+
 class BackupGenerator:
 	"""
 		This class contains methods to perform On Demand Backup
@@ -23,7 +23,8 @@ class BackupGenerator:
 		If specifying db_file_name, also append ".sql.gz"
 	"""
 	def __init__(self, db_name, user, password, backup_path_db=None, backup_path_files=None,
-		backup_path_private_files=None, db_host="localhost", db_port=3306):
+		backup_path_private_files=None, db_host="localhost", db_port=3306, verbose=False):
+		global _verbose
 		self.db_host = db_host
 		self.db_port = db_port or 3306
 		self.db_name = db_name
@@ -32,6 +33,8 @@ def __init__(self, db_name, user, password, backup_path_db=None, backup_path_fil
 		self.backup_path_files = backup_path_files
 		self.backup_path_db = backup_path_db
 		self.backup_path_private_files = backup_path_private_files
+		self.verbose = verbose
+		_verbose = verbose
 
 	def get_backup(self, older_than=24, ignore_files=False, force=False):
 		"""
@@ -103,7 +106,7 @@ def zip_files(self):
 			cmd_string = """tar -cf %s %s""" % (backup_path, files_path)
 			err, out = frappe.utils.execute_in_shell(cmd_string)
 
-			if verbose:
+			if self.verbose:
 				print('Backed up files', os.path.abspath(backup_path))
 
 	def take_dump(self):
@@ -159,21 +162,22 @@ def get_backup():
 	recipient_list = odb.send_email()
 	frappe.msgprint(_("Download link for your backup will be emailed on the following email address: {0}").format(', '.join(recipient_list)))
 
-def scheduled_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, force=False):
+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):
 	"""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)
+	odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=force, verbose=verbose)
 	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):
+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):
 	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_private_files=backup_path_private_files,
 						  db_host = frappe.db.host,
-						  db_port = frappe.db.port)
+						  db_port = frappe.db.port,
+						  verbose=verbose)
 	odb.get_backup(older_than, ignore_files, force=force)
 	return odb
 
@@ -202,20 +206,22 @@ def is_file_old(db_file_name, older_than=24):
 			file_datetime = datetime.fromtimestamp\
 						(os.stat(db_file_name).st_ctime)
 			if datetime.today() - file_datetime >= timedelta(hours = older_than):
-				if verbose: print("File is old")
+				if _verbose:
+					print("File is old")
 				return True
 			else:
-				if verbose: print("File is recent")
+				if _verbose:
+					print("File is recent")
 				return False
 		else:
-			if verbose: print("File does not exist")
+			if _verbose:
+				print("File does not exist")
 			return True
 
 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):
 	"Backup"
 	odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=True)
@@ -225,6 +231,7 @@ def backup(with_files=False, backup_path_db=None, backup_path_files=None, quiet=
 		"backup_path_private_files": odb.backup_path_private_files
 	}
 
+
 if __name__ == "__main__":
 	"""
 		is_file_old db_name user password db_host


Test patch: