modify: 完善服务器备份脚本 v1.0
This commit is contained in:
1 parent
b9a11f7382
commit
92c41b5192
1 file changed
+11
-7
+11
-7
@@ -14,19 +14,23 @@ echo '[ok] backup nginx data...'
|
|||||||
|
|
||||||
ssh -p 2001 root@cancerai.top "cd /home/nginx && tar -czf - -p --atime-preserve ." 2> /dev/null > ${curr_dir}/nginx/${datetime}.tar.gz
|
ssh -p 2001 root@cancerai.top "cd /home/nginx && tar -czf - -p --atime-preserve ." 2> /dev/null > ${curr_dir}/nginx/${datetime}.tar.gz
|
||||||
nginx_state=$?
|
nginx_state=$?
|
||||||
|
if [ ${nginx_state} -eq 0 ]; then
|
||||||
|
echo "[ok] backup nginx successful!"
|
||||||
|
else
|
||||||
|
echo "[error] backup nginx error, the backup files was deleted"
|
||||||
|
rm -rf ${curr_dir}/nginx/${datetime}.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[ok] backup git data..."
|
echo "[ok] backup git data..."
|
||||||
ssh -p 2001 root@cancerai.top "cd /home/git && tar -czf - -p --atime-preserve ." 2> /dev/null > ${curr_dir}/git/${datetime}.tar.gz
|
ssh -p 2001 root@cancerai.top "cd /home/git && tar -czf - -p --atime-preserve ." 2> /dev/null > ${curr_dir}/git/${datetime}.tar.gz
|
||||||
git_state=$?
|
git_state=$?
|
||||||
|
if [ ${git_state} -eq 0 ]; then
|
||||||
# if successful
|
echo "[ok] backup git successful!"
|
||||||
if [ ${nginx_state} -eq 0 ]; then
|
|
||||||
echo "[ok] backup successful!"
|
|
||||||
echo "[ok] current time: $(date +"%Y %m %d %H:%M:%S")"
|
|
||||||
echo "exit"
|
|
||||||
else
|
else
|
||||||
echo "[error] backup error, the backup files was deleted"
|
echo "[error] backup git error, the backup files was deleted"
|
||||||
rm -rf ${curr_dir}/nginx/${datetime}.tar.gz
|
rm -rf ${curr_dir}/nginx/${datetime}.tar.gz
|
||||||
rm -rf ${curr_dir}/git/${datetime}.tar.gz
|
rm -rf ${curr_dir}/git/${datetime}.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[ok] current time: $(date +"%Y %m %d %H:%M:%S")"
|
||||||
|
echo "exit"
|
||||||
Reference in new issue
Block a user