使用 restic 的 Kimai 备份脚本
相关文章:
- 如何在 Synology NAS 上安装 Restic REST 服务器 用于服务器设置(你也可以使用其他后端)
- 使用 docker-compose 和 nginx 的现代 Kimai 设置
配置备份脚本
首先,使用以下命令生成加密密码
kimai_backup.sh
pwgen 30 > .restic_password确保单独备份此密码,否则所有数据都将丢失!
kimai_backup.sh
#!/bin/bash
export NAME=$(basename $(pwd))
export RESTIC_REPOSITORY=rest:http://restic:abc123@10.1.2.3:16383/$NAME
export RESTIC_PASSWORD_FILE=.restic_password
if [ ! -f "${RESTIC_PASSWORD_FILE}" ]; then
echo "Please create .restic_password with the backup encryption password AND BACKUP THAT PASSWORD SEPARATELY!!!"
exit 1
fi
echo "Initing repo, please ignore any 'already exists' errors"
if [ ! -f ".restic_inited" ]; then
# Run the restic init command
restic init
if [ $? -eq 0 ]; then # if init successful
# Create the initialization file
touch ".restic_inited"
echo "Restic initialized"
fi
fi
# Backup
source .env
docker-compose exec -T mariadb mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases | restic --verbose backup --stdin --stdin-filename="mariadb.sql"
# Backup files
restic --verbose backup kimai_var backup.sh docker-compose.yml --exclude kimai_var/cache自动启动备份脚本
请参阅如何在 10 秒内创建 Systemd 备份计时器和服务
TL;DR: 在 backup.sh 所在的目录中,运行
install_backup_service.sh
wget -qO- https://techoverflow.net/scripts/create-backup-service.sh | sudo bash /dev/stdinCheck out similar posts by category:
Restic
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow