Spaces:
Running
Running
Rename sync_data.sh to backup_data.sh
Browse files
sync_data.sh → backup_data.sh
RENAMED
@@ -60,13 +60,13 @@ with requests.get(f'$FULL_WEBDAV_URL/{latest_backup}', auth=('$WEBDAV_USERNAME',
|
|
60 |
# 如果下载成功,且备份文件存在,则进行恢复
|
61 |
if os.path.exists(f'/tmp/{latest_backup}'):
|
62 |
# 如果data目录已存在,先删除以避免冲突
|
63 |
-
if os.path.exists('/home/app/
|
64 |
print('删除现有的data目录')
|
65 |
-
shutil.rmtree('/home/app/
|
66 |
|
67 |
# 解压tar.gz备份文件到指定目录
|
68 |
with tarfile.open(f'/tmp/{latest_backup}', 'r:gz') as tar:
|
69 |
-
tar.extractall('/home/app/
|
70 |
|
71 |
print(f'成功从 {latest_backup} 恢复备份')
|
72 |
else:
|
@@ -86,13 +86,13 @@ sync_data() {
|
|
86 |
echo "开始同步数据,时间:$(date)"
|
87 |
|
88 |
# 判断本地data目录是否存在,存在则打包上传
|
89 |
-
if [ -d "/home/app/
|
90 |
# 生成带时间戳的备份文件名
|
91 |
timestamp=$(date +%Y%m%d_%H%M%S)
|
92 |
backup_file="uptime_kuma_backup_${timestamp}.tar.gz"
|
93 |
|
94 |
-
# 进入
|
95 |
-
cd /home/app/
|
96 |
tar -czf "/tmp/${backup_file}" data
|
97 |
|
98 |
# 使用curl上传备份文件到WebDAV
|
|
|
60 |
# 如果下载成功,且备份文件存在,则进行恢复
|
61 |
if os.path.exists(f'/tmp/{latest_backup}'):
|
62 |
# 如果data目录已存在,先删除以避免冲突
|
63 |
+
if os.path.exists('/home/app/site-alert/data'):
|
64 |
print('删除现有的data目录')
|
65 |
+
shutil.rmtree('/home/app/site-alert/data')
|
66 |
|
67 |
# 解压tar.gz备份文件到指定目录
|
68 |
with tarfile.open(f'/tmp/{latest_backup}', 'r:gz') as tar:
|
69 |
+
tar.extractall('/home/app/site-alert/')
|
70 |
|
71 |
print(f'成功从 {latest_backup} 恢复备份')
|
72 |
else:
|
|
|
86 |
echo "开始同步数据,时间:$(date)"
|
87 |
|
88 |
# 判断本地data目录是否存在,存在则打包上传
|
89 |
+
if [ -d "/home/app/site-alert/data" ]; then
|
90 |
# 生成带时间戳的备份文件名
|
91 |
timestamp=$(date +%Y%m%d_%H%M%S)
|
92 |
backup_file="uptime_kuma_backup_${timestamp}.tar.gz"
|
93 |
|
94 |
+
# 进入site-alert目录,打包data目录到临时目录
|
95 |
+
cd /home/app/site-alert
|
96 |
tar -czf "/tmp/${backup_file}" data
|
97 |
|
98 |
# 使用curl上传备份文件到WebDAV
|