Debian Apache 服务器备份与恢复
一 备份范围与准备
二 快速备份步骤
三 快速恢复步骤
四 进阶与自动化
创建服务单元 /etc/systemd/system/backup-apache.service:
[Unit]
Description=Backup Apache files and configs
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/tar -czvf /backup/apache_files_$(date +%%F).tar.gz /var/www/html
ExecStart=/usr/bin/tar -czvf /backup/apache_configs_$(date +%%F).tar.gz /etc/apache2
创建定时器 /etc/systemd/system/backup-apache.timer:
[Unit]
Description=Daily Apache backup timer
Requires=backup-apache.service
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
启用:
sudo systemctl daemon-reload
sudo systemctl enable --now backup-apache.timer
五 常见问题与排错