Restic systemd
init repo⌗
apt install -y restic
export AWS_ACCESS_KEY_ID='KEY_ID_HERE'
export AWS_SECRET_ACCESS_KEY='ACCESS_KEY_HERE'
export RESTIC_REPOSITORY="REPO_HERE_IS_USE_MINIO"
export RESTIC_PASSWORD='RANDOM_PASSWD_HERE'
restic init
Service time⌗
nano /etc/systemd/system/restic-backup.service
[Unit]
Description=restic
Wants=restic.timer
[Service]
Type=oneshot
User=root
Group=root
Environment=AWS_ACCESS_KEY_ID='KEY_ID_HERE'
Environment=AWS_SECRET_ACCESS_KEY='ACCESS_KEY_HERE'
Environment=RESTIC_REPOSITORY="REPO_HERE_IS_USE_MINIO"
Environment=RESTIC_PASSWORD='RANDOM_PASSWD_HERE'
ExecStartPre=/bin/bash -c '/usr/bin/mysqldump --defaults-file=/root/.my.cnf --all-databases > /opt/backup/mysqldump.sql'
ExecStart=/bin/bash -c '/usr/bin/restic --exclude={/dev,/media,/mnt,/proc,/run,/sys,/tmp,/var/tmp,/var/lib/mysql,/swap*} backup / && /usr/bin/restic forget --prune --keep-daily 5 --keep-weekly 15 --keep-monthly 15'
ExecStartPost=/usr/bin/rm /opt/backup/mysqldump.sql
[Install]
WantedBy=multi-user.target
Timer time⌗
nano /etc/systemd/system/restic-backup.timer
[Unit]
Description=restic
Requires=restic.service
[Timer]
Unit=restic.service
OnCalendar=daily
AccuracySec=1h
Persistent=true
[Install]
WantedBy=timers.target
Reload and enable timer⌗
systemctl daemon-reload
systemctl enable restic.timer --now
You should now have a working restic repo⌗
<- OTHERS ->