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
|
||||
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..."
|
||||
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=$?
|
||||
|
||||
# if successful
|
||||
if [ ${nginx_state} -eq 0 ]; then
|
||||
echo "[ok] backup successful!"
|
||||
echo "[ok] current time: $(date +"%Y %m %d %H:%M:%S")"
|
||||
echo "exit"
|
||||
if [ ${git_state} -eq 0 ]; then
|
||||
echo "[ok] backup git successful!"
|
||||
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}/git/${datetime}.tar.gz
|
||||
fi
|
||||
|
||||
echo "[ok] current time: $(date +"%Y %m %d %H:%M:%S")"
|
||||
echo "exit"
|
||||
Reference in new issue
Block a user