Fetching metadata from the HF Docker repository...
-
Update sync_data.sh Running
-
Update sync_data.sh
-
Update sync_data.sh
-
Update sync_data.sh
-
Update sync_data.sh
-
Update sync_data.sh
-
Update sync_data.sh
-
Update sync_data.sh
#!/bin/bash
mkdir -p ./data
# 设置默认值
WEBDAV_PATH=${WEBDAV_PATH:-"openwebui"} # 默认子目录
WEBDAV_MAXBACKUP=${WEBDAV_MAXBACKUP:-3} # 默认保留3个备份
LAST_BACKUP_DATE_FILE="./data/last_backup_date.txt" # 记录上次备份日期
# 生成校验和文件
generate_sum() {
local file=$1
local sum_file=$2
sha256sum "$file" > "$sum_file"
}
# 清理旧的WebDAV备份
clean_old_backups() {
echo "清理超过${WEBDAV_MAXBACKUP}个的旧备份..."
# 获取WebDAV上现有的备份文件列表(按日期排序)
BACKUP_LIST=$(curl -s -L --user "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" "$WEBDAV_URL/$WEBDAV_PATH/" | grep -o 'webui_[0-9]\{8\}.db' | sort -r)
# 计算需要删除的文件数
COUNT=$(echo "$BACKUP_LIST" | wc -l)
if [ "$COUNT" -gt "$WEBDAV_MAXBACKUP" ]; then
TO_DELETE=$((COUNT - WEBDAV_MAXBACKUP))
echo "需要删除${TO_DELETE}个旧备份"
# 删除最旧的备份
echo "$BACKUP_LIST" | tail -n $TO_DELETE | while read -r file; do
echo "正在删除: $file"
curl -X DELETE -L --user "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" "$WEBDAV_URL/$WEBDAV_PATH/$f…
-
Update sync_data.sh
-
Create sync_data.sh