Update run.sh
Browse files
run.sh
CHANGED
|
@@ -112,7 +112,7 @@ do_backup_and_rotate() {
|
|
| 112 |
tar --exclude='logs' --exclude='tmp' --ignore-failed-read -czf "$TEMP_PATH" -C "$DATA_DIR" .
|
| 113 |
|
| 114 |
if [ $? -le 1 ]; then
|
| 115 |
-
if curl $CURL_ARGS -T "$TEMP_PATH" "${WEBDAV_URL}${NEW_BACKUP_NAME}"; then
|
| 116 |
echo "✅ 备份上传成功"
|
| 117 |
# 更新索引
|
| 118 |
curl $CURL_ARGS "$INDEX_URL" -o /tmp/backups.txt 2>/dev/null || touch /tmp/backups.txt
|
|
@@ -130,7 +130,7 @@ do_backup_and_rotate() {
|
|
| 130 |
tail -n "$MAX_BACKUPS" /tmp/backups.txt > /tmp/new_backups.txt
|
| 131 |
mv /tmp/new_backups.txt /tmp/backups.txt
|
| 132 |
fi
|
| 133 |
-
curl $CURL_ARGS -T /tmp/backups.txt "$INDEX_URL"
|
| 134 |
touch "$MARKER_FILE"
|
| 135 |
else
|
| 136 |
echo "❌ 备份上传失败,请检查 WebDAV 配置"
|
|
@@ -161,17 +161,17 @@ restore_latest() {
|
|
| 161 |
return
|
| 162 |
fi
|
| 163 |
|
| 164 |
-
# 先验证 WebDAV 连通性
|
| 165 |
echo "🔍 正在验证 WebDAV 连接..."
|
| 166 |
-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -L --connect-timeout 10 \
|
| 167 |
${WEBDAV_USER:+-u "$WEBDAV_USER:$WEBDAV_PASSWORD"} \
|
| 168 |
"${WEBDAV_URL}")
|
| 169 |
-
if [[ "$HTTP_CODE"
|
| 170 |
-
echo "❌ WebDAV 连接失败
|
| 171 |
generate_config
|
| 172 |
return
|
| 173 |
fi
|
| 174 |
-
echo "✅ WebDAV 连接正常"
|
| 175 |
|
| 176 |
echo "🔍 正在从 WebDAV 检查数据..."
|
| 177 |
if curl $CURL_ARGS "$INDEX_URL" -o /tmp/backups.txt; then
|
|
|
|
| 112 |
tar --exclude='logs' --exclude='tmp' --ignore-failed-read -czf "$TEMP_PATH" -C "$DATA_DIR" .
|
| 113 |
|
| 114 |
if [ $? -le 1 ]; then
|
| 115 |
+
if curl $CURL_ARGS -o /dev/null -T "$TEMP_PATH" "${WEBDAV_URL}${NEW_BACKUP_NAME}"; then
|
| 116 |
echo "✅ 备份上传成功"
|
| 117 |
# 更新索引
|
| 118 |
curl $CURL_ARGS "$INDEX_URL" -o /tmp/backups.txt 2>/dev/null || touch /tmp/backups.txt
|
|
|
|
| 130 |
tail -n "$MAX_BACKUPS" /tmp/backups.txt > /tmp/new_backups.txt
|
| 131 |
mv /tmp/new_backups.txt /tmp/backups.txt
|
| 132 |
fi
|
| 133 |
+
curl $CURL_ARGS -o /dev/null -T /tmp/backups.txt "$INDEX_URL"
|
| 134 |
touch "$MARKER_FILE"
|
| 135 |
else
|
| 136 |
echo "❌ 备份上传失败,请检查 WebDAV 配置"
|
|
|
|
| 161 |
return
|
| 162 |
fi
|
| 163 |
|
| 164 |
+
# 先验证 WebDAV 连通性(用 OPTIONS 方法,WebDAV 标准)
|
| 165 |
echo "🔍 正在验证 WebDAV 连接..."
|
| 166 |
+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X OPTIONS -L --connect-timeout 10 \
|
| 167 |
${WEBDAV_USER:+-u "$WEBDAV_USER:$WEBDAV_PASSWORD"} \
|
| 168 |
"${WEBDAV_URL}")
|
| 169 |
+
if [[ "$HTTP_CODE" == "000" ]]; then
|
| 170 |
+
echo "❌ WebDAV 连接失败(无法连接),请检查 WEBDAV_URL"
|
| 171 |
generate_config
|
| 172 |
return
|
| 173 |
fi
|
| 174 |
+
echo "✅ WebDAV 连接正常 (HTTP $HTTP_CODE)"
|
| 175 |
|
| 176 |
echo "🔍 正在从 WebDAV 检查数据..."
|
| 177 |
if curl $CURL_ARGS "$INDEX_URL" -o /tmp/backups.txt; then
|