2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-12 18:59:06 +00:00

Fix confluentdbrestore in non-root environments

This commit is contained in:
Jarrod Johnson 2020-08-14 07:16:04 -04:00
parent aab27ccc4b
commit ec42a2aad8
2 changed files with 9 additions and 0 deletions

View File

@ -62,11 +62,19 @@ if args[0] == 'restore':
if pid is not None:
print("Confluent is running, must shut down to restore db")
sys.exit(1)
stinf = os.stat('/etc/confluent')
owner = stinf.st_uid
group = stinf.st_gid
password = options.password
if options.interactivepassword:
password = getpass.getpass('Enter password to restore backup: ')
try:
cfm.restore_db_from_directory(dumpdir, password)
if owner != 0:
for targdir in os.walk('/etc/confluent'):
os.chown(targdir[0], owner, group)
for f in targdir[2]:
os.chown(os.patht.join(targdir[0], f), owner, group)
except Exception as e:
print(str(e))
sys.exit(1)

View File

@ -2674,6 +2674,7 @@ def restore_db_from_directory(location, password):
with open(os.path.join(location, 'main.json'), 'r') as cfgfile:
cfgdata = cfgfile.read()
ConfigManager(tenant=None)._load_from_json(cfgdata)
ConfigManager.wait_for_sync(True)
def dump_db_to_directory(location, password, redact=None, skipkeys=False):