Skip to content

Commit f0f6082

Browse files
authored
fix: nebula backup and restore failed (#2435)
1 parent 1bb19fa commit f0f6082

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

addons/nebula/dataprotection/br-backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
set -eo pipefail
32

43
toolConfig=/etc/datasafed/datasafed.conf
54

@@ -31,6 +30,7 @@ if [ -n "$region" ]; then
3130
fi
3231

3332
meta_ep=$(echo $NEBULA_METAD_SVC | cut -d',' -f1)
33+
set -eo pipefail
3434
br backup full --meta ${meta_ep} --s3.endpoint "${endpoint}" \
3535
--storage="s3://${bucket}${DP_BACKUP_BASE_PATH}" --s3.access_key="${access_key_id}" \
3636
--s3.secret_key="${secret_access_key}" ${region_flag}

addons/nebula/dataprotection/br-restore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
set -eo pipefail
32

43
toolConfig=/etc/datasafed/datasafed.conf
54

@@ -29,6 +28,7 @@ backup_name=$(datasafed list -d / | sort -Vr | head -n 1)
2928
backup_name=$(basename $backup_name)
3029

3130
meta_ep=$(echo $NEBULA_METAD_SVC | cut -d',' -f1)
31+
set -eo pipefail
3232
br restore full --meta ${meta_ep} --s3.endpoint "${endpoint}" \
3333
--storage="s3://${bucket}/${DP_BACKUP_BASE_PATH}" --s3.access_key="${access_key_id}" \
3434
--s3.secret_key="${secret_access_key}" --name ${backup_name} ${region_flag}

addons/nebula/scripts/common.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ function nebula_service_start() {
3636
cp ${root_dir}/config/nebula-$1.conf ${root_dir}/etc/nebula-$1.conf
3737
printf "\n--local_ip=${POD_FQDN}" >> ${root_dir}/etc/nebula-$1.conf
3838
${root_dir}/scripts/nebula.service -c ${root_dir}/etc/nebula-$1.conf start $1
39+
wait_service_ready
40+
}
41+
42+
function wait_service_ready() {
43+
count=0
44+
set +e
45+
while true; do
46+
if [ $count -gt 10 ]; then
47+
echo "Service is not ready after waiting for a long time"
48+
exit 1
49+
fi
50+
count=$((count+1))
51+
response=$(curl -s http://127.0.0.1:${HTTP_PORT}/status)
52+
if echo "$response" | grep "running"; then
53+
echo "Service is ready"
54+
break
55+
fi
56+
sleep 3
57+
done
58+
set -e
3959
}
4060

4161
function start_nebula_agent() {
@@ -51,4 +71,12 @@ function end_restore() {
5171
${root_dir}/scripts/nebula.service stop $1
5272
check_service_is_stopped $1
5373
rm -f ${root_dir}/logs/.kb_agent
74+
}
75+
76+
function check_agent() {
77+
pid=`ps -eo pid,args | grep -F "/usr/local/nebula/console/agent" | grep -v "grep" | tail -1 | awk '{print $1}'`
78+
if [ -z "$pid" ]; then
79+
echo "$(date): Nebula agent process is not running, exit..."
80+
exit 1
81+
fi
5482
}

addons/nebula/scripts/start-agent.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ if [ -f "/usr/local/nebula/logs/.kb_restore" ]; then
1818
echo "$(date): Nebula restoration completed."
1919
break
2020
fi
21+
pid=`ps -eo pid,args | grep -F "restore-agent" | grep -v "grep" | tail -1 | awk '{print $1}'`
22+
if [ -z "$pid" ]; then
23+
echo "restore-agent is not running, exit..."
24+
exit 1
25+
fi
2126
echo "$(date): Waiting for Nebula restoration to complete..."
2227
done
2328
# kill restore-agent if it is still running

addons/nebula/scripts/start-graphd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ if [ -f "${root_dir}/logs/.kb_restore" ]; then
2020
end_restore graphd
2121
break
2222
fi
23+
check_agent
2324
echo "$(date): Waiting for Nebula restoration to complete..."
2425
done
2526
fi

addons/nebula/scripts/start-metad.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if [ -f "${root_dir}/logs/.kb_restore" ]; then
2424
end_restore metad
2525
break
2626
fi
27+
check_agent
2728
echo "$(date): Waiting for Nebula restoration to complete..."
2829
done
2930
fi

addons/nebula/scripts/start-storaged.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ if [ -f "${root_dir}/logs/.kb_restore" ]; then
4747
end_restore storaged
4848
break
4949
fi
50+
check_agent
5051
echo "$(date): Waiting for Nebula restoration to complete..."
5152
done
5253
fi

0 commit comments

Comments
 (0)