Hi Guys i wanted to share zabbix template for restic in dockers,
Wanted to say thanks for the restic community for this amazing software
Currently using GitHub - djmaze/resticker: Run automatic restic backups via a Docker container. as for the restic docker
This is my currently docker-compose.yml change according to your environment
In this example im backing up mysql docker containers and postgresql and sending to sftp server location
remember to create the ssh-keygen if your using sftp to another host or else the docker container wont be able to password-less ssh
version: "3.3"
services:
sftp_backup:
image: mazzolino/restic
restart: always
hostname: wpsftp-backup
privileged: true
environment:
RUN_ON_STARTUP: "false"
PRE_COMMANDS: |-
sleep 20
docker exec restic_sftp_backup_1 restic unlock
docker exec restic_sftp_check_1 restic unlock
docker exec restic_sftp-prune_1 restic unlock
docker exec openproject_db_1 pg_dump -U postgres -d openproject | restic backup --tag pgsqlbackupsftp --stdin --stdin-filename openproject.sql
docker exec lyntik_db_1 mysqldump -u root -pmypassword --all-databases | restic backup --tag mysqlbackupsft --stdin --stdin-filename wordpress.sql
POST_COMMANDS_FAILURE: |-
curl -X POST --data "{\"title\": \"Backup failed\", \"body\": \"\"}" http://notify:5000
BACKUP_CRON: "0 30 23 * * *"
RESTIC_REPOSITORY: sftp:root@192.168.7.253:/media/usb/dockers
RESTIC_PASSWORD: mypassw
RESTIC_BACKUP_SOURCES: /dockers
RESTIC_BACKUP_ARGS: >-
--tag dockers
--verbose
RESTIC_FORGET_ARGS: >-
--keep-last 90
TZ: America/Bogota
volumes:
- /swag:/dockers/swag
- /var/lib/docker/volumes/openproject_opdata/_data:/dockers/project
- /root/.ssh/:/root/.ssh/
- /var/run/docker.sock:/var/run/docker.sock
networks:
- notification
sftp-prune:
image: mazzolino/restic
hostname: wpsftp-prune
environment:
RUN_ON_STARTUP: "false"
PRUNE_CRON: "0 0 4 * * *"
RESTIC_REPOSITORY: sftp:root@192.168.7.253:/media/usb/dockers
RESTIC_PASSWORD: mypassw
volumes:
- /root/.ssh/:/root/.ssh/
sftp_check:
image: mazzolino/restic
hostname: wpsftp-check
environment:
RUN_ON_STARTUP: "false"
CHECK_CRON: "0 15 5 * * *"
RESTIC_CHECK_ARGS: >-
--read-data-subset=10%
RESTIC_REPOSITORY: sftp:root@192.168.7.253:/media/usb/dockers
RESTIC_PASSWORD: mypassw
TZ: America/Bogota
volumes:
- /root/.ssh/:/root/.ssh/
notify:
image: mazzolino/apprise-microservice:0.1
environment:
NOTIFICATION_URLS: mailtos://alerts:mypassword@domain.com/alerts@mydomain.com/alerts@mydomain.com?smtp=mail.domanin.com&port=465&name=Dockers%20Backup%20Notification
networks:
- notification
networks:
notification:
after getting that setup were going to assume you have zabbix server working with zabbix agent on the host that is containing the docker restic
were going to create these folders on the host
mkdir /etc/zabbix/scripts
mkdir -p /var/log/restic/scripts
then were going to clone the repo
git clone https://github.com/killmasta93/restic.git
then we cd the folder copy the scripts to the location below
cd restic
cp added.sh bytes.sh delpacks.sh freedspace.sh message.sh packs.sh policy.sh remfiles.sh rewpacks.sh size.sh snapshotid.sh time.sh /etc/zabbix/scripts/
cp container-log.sh log.sh /var/log/restic/scripts/
then give it permissions
cd /etc/zabbix/
chmod -R 777 scripts/
then we need to add user parameters, add it underneath the general parameters
nano /etc/zabbix/zabbix_agent2.conf
UserParameter=restic.backup.processedtime,/bin/bash /etc/zabbix/scripts/time.sh --value "$1"
UserParameter=restic.backup.snapshotid,/bin/bash /etc/zabbix/scripts/snapshotid.sh --value "$1"
UserParameter=restic.backup.processedbytes,/bin/bash /etc/zabbix/scripts/bytes.sh --value "$1"
UserParameter=restic.backup.added,/bin/bash /etc/zabbix/scripts/added.sh --value "$1"
UserParameter=restic.check.message,/bin/bash /etc/zabbix/scripts/message.sh --value "$1"
UserParameter=restic.prune.freedspace,/bin/bash /etc/zabbix/scripts/freedspace.sh --value "$1"
UserParameter=restic.prune.remfiles,/bin/bash /etc/zabbix/scripts/remfiles.sh --value "$1"
UserParameter=restic.prune.packs,/bin/bash /etc/zabbix/scripts/packs.sh --value "$1"
UserParameter=restic.prune.delpacks,/bin/bash /etc/zabbix/scripts/delpacks.sh --value "$1"
UserParameter=restic.prune.rewpacks,/bin/bash /etc/zabbix/scripts/rewpacks.sh --value "$1"
UserParameter=restic.prune.policy,/bin/bash /etc/zabbix/scripts/policy.sh --value "$1"
UserParameter=restic.prune.size,/bin/bash /etc/zabbix/scripts/size.sh --value "$1"
Then create the logs files
touch /var/log/restic/latest-backup.log
touch /var/log/restic/check-container.log
touch /var/log/restic/latest-check.log
touch /var/log/restic/latest-prune.log
touch /var/log/restic/prune-container.log
also give permissions
cd /var/log/restic/scripts
chmod 777 container-log.sh log.sh
then restart zabbix agent and add the template to the host
Hope this helps someone, open to ideas
Thanks