@@ -27,6 +27,11 @@ def create_tmp_ton_dir(self):
2727 self .create_keyring (dir_name_db )
2828 return dir_name
2929
30+ @staticmethod
31+ def run_create_backup (args ):
32+ backup_script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/create_backup.sh' )
33+ return subprocess .run (["bash" , backup_script_path ] + args , timeout = 5 )
34+
3035 def create_backup (self , args ):
3136 if len (args ) > 1 :
3237 color_print ("{red}Bad args. Usage:{endc} create_backup [filename]" )
@@ -35,8 +40,7 @@ def create_backup(self, args):
3540 command_args = ["-m" , self .ton .local .buffer .my_work_dir , "-t" , tmp_dir ]
3641 if len (args ) == 1 :
3742 command_args += ["-d" , args [0 ]]
38- backup_script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/create_backup.sh' )
39- process = subprocess .run (["bash" , backup_script_path ] + command_args , timeout = 5 )
43+ process = self .run_create_backup (command_args )
4044
4145 if process .returncode == 0 :
4246 color_print ("create_backup - {green}OK{endc}" )
@@ -46,6 +50,11 @@ def create_backup(self, args):
4650 return process .returncode
4751 # end define
4852
53+ @staticmethod
54+ def run_restore_backup (args ):
55+ restore_script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/restore_backup.sh' )
56+ return run_as_root (["bash" , restore_script_path ] + args )
57+
4958 def restore_backup (self , args ):
5059 if len (args ) == 0 or len (args ) > 2 :
5160 color_print ("{red}Bad args. Usage:{endc} restore_backup <filename> [-y]" )
@@ -67,8 +76,7 @@ def restore_backup(self, args):
6776 ip = str (ip2int (get_own_ip ()))
6877 command_args = ["-m" , self .ton .local .buffer .my_work_dir , "-n" , args [0 ], "-i" , ip ]
6978
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 :
79+ if self .run_restore_backup (command_args ) == 0 :
7280 color_print ("restore_backup - {green}OK{endc}" )
7381 self .local .exit ()
7482 else :
0 commit comments