Skip to content

Commit 4f48732

Browse files
committed
remove mytoncore restart from backup, remove -y flag
1 parent 6a9a2c5 commit 4f48732

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

modules/backups.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ def create_tmp_ton_dir(self):
2727
return dir_name
2828

2929
def create_backup(self, args):
30-
if len(args) > 2:
31-
color_print("{red}Bad args. Usage:{endc} create_backup [filename] [-y]")
30+
if len(args) > 1:
31+
color_print("{red}Bad args. Usage:{endc} create_backup [filename]")
3232
return
33-
if '-y' not in args:
34-
res = input(f'Mytoncore service will be stopped for few seconds while backup is created, Proceed [y/n]?')
35-
if res.lower() != 'y':
36-
print('aborted.')
37-
return
38-
else:
39-
args.pop(args.index('-y'))
4033
dir_ = self.create_tmp_ton_dir()
4134
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-t", dir_]
4235
if len(args) == 1:
@@ -64,7 +57,7 @@ def restore_backup(self, args):
6457
else:
6558
args.pop(args.index('-y'))
6659
print('Before proceeding, mtc will create a backup of current configuration.')
67-
self.create_backup(['-y'])
60+
self.create_backup([])
6861
ip = str(ip2int(get_own_ip()))
6962
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-n", args[0], "-i", ip]
7063

mytoncore/mytoncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ def make_backup(self, election_id: str):
14861486
os.makedirs(backups_dir, exist_ok=True)
14871487
args.append(backups_dir + name)
14881488
self.clear_dir(backups_dir)
1489-
exit_code = module.create_backup(args + ['-y'])
1489+
exit_code = module.create_backup(args)
14901490
if exit_code != 0:
14911491
self.local.add_log(f"Backup failed with exit code {exit_code}", "error")
14921492
else:

mytonctrl/scripts/create_backup.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ done
2020
COLOR='\033[92m'
2121
ENDC='\033[0m'
2222

23-
systemctl stop mytoncore
24-
25-
echo -e "${COLOR}[1/4]${ENDC} Stopped mytoncore service"
26-
27-
28-
tmp_dir="/tmp/mytoncore/backup"
23+
tmp_dir="/tmp/mytoncore/backupv2"
2924
rm -rf $tmp_dir
3025
mkdir $tmp_dir
3126
mkdir $tmp_dir/db
@@ -36,16 +31,15 @@ cp -r $keys_dir ${tmp_dir}
3631
cp -r $mtc_dir $tmp_dir
3732

3833
python3 -c "import json;f=open('${tmp_dir}/db/config.json');json.load(f);f.close()" || exit 1 # Check if config.json is copied correctly
34+
python3 -c "import json;f=open('${tmp_dir}/mytoncore/mytoncore.db');json.load(f);f.close()" || exit 2 # Check if mytoncore.db is copied correctly
3935

40-
echo -e "${COLOR}[2/4]${ENDC} Copied files to ${tmp_dir}"
41-
42-
systemctl start mytoncore
36+
echo -e "${COLOR}[1/3]${ENDC} Copied files to ${tmp_dir}"
4337

44-
echo -e "${COLOR}[3/4]${ENDC} Started mytoncore service"
38+
echo -e "${COLOR}[2/3]${ENDC} Started mytoncore service"
4539

4640
tar -zcf $dest -C $tmp_dir .
4741

4842
chown $user:$user $dest
4943

50-
echo -e "${COLOR}[4/4]${ENDC} Backup successfully created in ${dest}!"
44+
echo -e "${COLOR}[3/3]${ENDC} Backup successfully created in ${dest}!"
5145
echo -e "If you wish to use archive package to migrate node to different machine please make sure to stop validator and mytoncore on donor (this) host prior to migration."

0 commit comments

Comments
 (0)