Skip to content

Commit 9114bb2

Browse files
committed
update restoring backup
1 parent 7128e9c commit 9114bb2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

modules/backups.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ def create_backup(self, args):
4646
return process.returncode
4747
# end define
4848

49+
@staticmethod
50+
def run_restore_backup(args):
51+
restore_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/restore_backup.sh')
52+
return run_as_root(["bash", restore_script_path] + args)
53+
4954
def restore_backup(self, args):
5055
if len(args) == 0 or len(args) > 2:
5156
color_print("{red}Bad args. Usage:{endc} restore_backup <filename> [-y]")
@@ -67,8 +72,7 @@ def restore_backup(self, args):
6772
ip = str(ip2int(get_own_ip()))
6873
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-n", args[0], "-i", ip]
6974

70-
restore_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/restore_backup.sh')
71-
if run_as_root(["bash", restore_script_path] + command_args) == 0:
75+
if self.run_restore_backup(command_args) == 0:
7276
color_print("restore_backup - {green}OK{endc}")
7377
self.local.exit()
7478
else:

mytoninstaller/settings.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -938,18 +938,14 @@ def set_external_ip(local, ip):
938938
def ConfigureFromBackup(local):
939939
if not local.buffer.backup:
940940
return
941-
from mytoncore import MyTonCore
942-
from mypylib.mypylib import MyPyClass # todo move to file header
943941
from modules.backups import BackupModule
944942
mconfig_path = local.buffer.mconfig_path
945943
mconfig_dir = get_dir_from_path(mconfig_path)
946944
local.add_log("start ConfigureFromBackup function", "info")
947945
backup_file = local.buffer.backup
948946

949-
ton = MyTonCore(MyPyClass('mytoncore.py'))
950-
ton.local.buffer.my_work_dir = mconfig_dir
951-
module = BackupModule(ton, local)
952-
module.restore_backup([backup_file, '-y'])
947+
os.makedirs(local.buffer.ton_work_dir, exist_ok=True)
948+
BackupModule.run_restore_backup(["-m", mconfig_dir, "-n", backup_file])
953949

954950
if local.buffer.only_mtc:
955951
local.add_log("Installing only mtc", "info")

0 commit comments

Comments
 (0)