v2.5: 修复rsync exclude路径格式

This commit is contained in:
mango
2026-02-02 09:30:54 +08:00
parent 5f29fbaa1f
commit cc13e8e4ff

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#=============================================================================== #===============================================================================
# VPS 快照备份脚本 v2.4 # VPS 快照备份脚本 v2.5
# 支持: Ubuntu, Debian, CentOS, Alpine # 支持: Ubuntu, Debian, CentOS, Alpine
# 功能: 创建/恢复快照 + rsync 远程同步 + Telegram 通知 + 自动清理 # 功能: 创建/恢复快照 + rsync 远程同步 + Telegram 通知 + 自动清理
#=============================================================================== #===============================================================================
@@ -22,7 +22,7 @@ SSH_KEY_PATH="/root/.ssh/vps_snapshot_key"
print_banner() { print_banner() {
echo -e "${BLUE}" echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════════════════════╗" echo "╔═══════════════════════════════════════════════════════════╗"
echo "║ VPS 快照备份脚本 v2.4 ║" echo "║ VPS 快照备份脚本 v2.5 ║"
echo "║ 支持 Ubuntu/Debian/CentOS/Alpine ║" echo "║ 支持 Ubuntu/Debian/CentOS/Alpine ║"
echo "╚═══════════════════════════════════════════════════════════╝" echo "╚═══════════════════════════════════════════════════════════╝"
echo -e "${NC}" echo -e "${NC}"
@@ -386,36 +386,35 @@ do_restore() {
log "完整恢复: rsync --delete" log "完整恢复: rsync --delete"
rsync -aAXv --delete \ rsync -aAXv --delete \
--exclude='/proc/*' \ --exclude='proc' \
--exclude='/sys/*' \ --exclude='sys' \
--exclude='/dev/*' \ --exclude='dev' \
--exclude='/run/*' \ --exclude='run' \
--exclude='/tmp/*' \ --exclude='tmp' \
--exclude='/mnt/*' \ --exclude='mnt' \
--exclude='/media/*' \ --exclude='media' \
--exclude='/lost+found' \ --exclude='lost+found' \
--exclude='/etc/ssh/*' \ --exclude='etc/ssh' \
--exclude='/root/.ssh/*' \ --exclude='root/.ssh' \
--exclude='/etc/shadow' \ --exclude='etc/shadow' \
--exclude='/etc/passwd' \ --exclude='etc/passwd' \
--exclude='/etc/hostname' \ --exclude='etc/hostname' \
--exclude='/etc/hosts' \ --exclude='etc/hosts' \
--exclude='/etc/network/*' \ --exclude='etc/network' \
--exclude='/etc/netplan/*' \ --exclude='etc/netplan' \
--exclude="$LOCAL_DIR/*" \ --exclude='var/snapshots' \
--exclude="$temp_dir" \
"$temp_dir/" / "$temp_dir/" /
else else
log "覆盖恢复" log "覆盖恢复"
rsync -aAXv \ rsync -aAXv \
--exclude='/etc/ssh/*' \ --exclude='etc/ssh' \
--exclude='/root/.ssh/*' \ --exclude='root/.ssh' \
--exclude='/etc/shadow' \ --exclude='etc/shadow' \
--exclude='/etc/passwd' \ --exclude='etc/passwd' \
--exclude='/etc/hostname' \ --exclude='etc/hostname' \
--exclude='/etc/hosts' \ --exclude='etc/hosts' \
--exclude='/etc/network/*' \ --exclude='etc/network' \
--exclude='/etc/netplan/*' \ --exclude='etc/netplan' \
"$temp_dir/" / "$temp_dir/" /
fi fi