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:
parent
aab27ccc4b
commit
ec42a2aad8
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user