From a956388a1a9613a2e129cb65409e0e0a66184fad Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 4 Aug 2020 11:11:58 +0100 Subject: [PATCH] fix: grant privileges for rds when restoring backup --- build/common/commands/restore_backup.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/build/common/commands/restore_backup.py b/build/common/commands/restore_backup.py index 474ff3ee..6368d03a 100644 --- a/build/common/commands/restore_backup.py +++ b/build/common/commands/restore_backup.py @@ -12,7 +12,7 @@ from frappe.installer import ( make_site_dirs, update_site_config ) -from constants import COMMON_SITE_CONFIG_FILE, DATE_FORMAT +from constants import COMMON_SITE_CONFIG_FILE, DATE_FORMAT, RDS_DB, RDS_PRIVILEGES from utils import ( run_command, list_directories, @@ -227,8 +227,15 @@ def restore_mariadb(config, site_config, database_file): run_command(create_user) # grant db privileges to user - grant_privileges = mysql_command + ["-e", f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%' IDENTIFIED BY '{db_password}'; FLUSH PRIVILEGES;"] - run_command(grant_privileges) + + grant_privileges = "ALL PRIVILEGES" + + # for Amazon RDS + if config.get(RDS_DB) or site_config.get(RDS_DB): + grant_privileges = RDS_PRIVILEGES + + grant_privileges_command = mysql_command + ["-e", f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%' IDENTIFIED BY '{db_password}'; FLUSH PRIVILEGES;"] + run_command(grant_privileges_command) print('Restoring MariaDB') with open(database_file.replace('.gz', ''), 'r') as db_file: