: restic munin plugins

This commit is contained in:
VC
2025-02-25 07:56:29 +01:00
parent e7a070d099
commit aa4ff098fc
6 changed files with 91 additions and 2 deletions

View File

@@ -12,3 +12,4 @@ restic_aws_secret_access_key: !vault |
38376163613837626435373134393630316235313032353738643537303162643538353966613833
34333735663939396433
restic_s3_url: "s3:http://backup.mateu.be:3900/backup"
restic_summary_log: "/var/log/restic/summary.json"

View File

@@ -0,0 +1,49 @@
#!/bin/bash
case $1 in
config)
cat << 'EOF'
multigraph restic_file_processed
graph_title Files/dirs processed by restic
graph_vlabel Number of files/dirs processed by restic
graph_args --base 1000 -l 0
graph_category restic
files_new.label files_new
files_changed.label files_changed
files_unmodified.label files_unmodified
dirs_new.label dirs_new
dirs_changed.label dirs_changed
dirs_unmodified.label dirs_unmodified
EOF
cat << 'EOF'
multigraph restic_data_added
graph_title Data added to repo by restic
graph_vlabel Data added in bytes
graph_args --base 1024 -l 0
graph_category restic
data_added.label raw_data_added
data_added_packed.label compressed_data_added
EOF
cat << 'EOF'
multigraph restic_backup_duration
graph_title Restic backup duration
graph_vlabel Duration of restic backup (seconds)
graph_args --base 1000 -l 0
graph_category restic
total_duration.label total_duration
EOF
exit 0;;
esac
echo "multigraph restic_file_processed"
echo "files_new.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .files_new)"
echo "files_changed.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .files_changed)"
echo "files_unmodified.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .files_unmodified)"
echo "dirs_new.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .dirs_new)"
echo "dirs_changed.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .dirs_changed)"
echo "dirs_unmodified.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .dirs_unmodified)"
echo "multigraph restic_data_added"
echo "data_added.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .data_added)"
echo "data_added_packed.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .data_added_packed)"
echo "multigraph restic_backup_duration"
echo "total_duration.value $(cat ${RESTIC_SUMMARY_LOG} | jq -r .total_duration)"

View File

@@ -135,3 +135,8 @@
- name: Execute specific garage commands
ansible.builtin.include_tasks: garage.yml
when: "'garageservers' in group_names"
# Specific restic commands
- name: Execute specific restic commands
ansible.builtin.include_tasks: restic.yml
when: "'resticservers' in group_names"

View File

@@ -0,0 +1,28 @@
---
- name: Ensure some packages are installed
ansible.builtin.package:
name:
- jq
state: present
update_cache: true
- name: Put restic plugin configuration
ansible.builtin.template:
src: restic.j2
dest: /etc/munin/plugin-conf.d/restic
owner: root
group: root
mode: "0o640"
notify:
- Restart munin-node
- name: Put restic scripts
ansible.builtin.copy:
src: files/restic_backup
dest: /etc/munin/plugins/restic_backup
owner: root
group: root
mode: "0o755"
notify:
- Restart munin-node

View File

@@ -0,0 +1,3 @@
[restic_backup]
env.RESTIC_SUMMARY_LOG {{ restic_summary_log }}

View File

@@ -6,8 +6,11 @@ export RESTIC_REPOSITORY="{{ restic_repository }}"
export AWS_ACCESS_KEY_ID="{{ restic_aws_access_key_id }}"
export AWS_SECRET_ACCESS_KEY="{{ restic_aws_secret_access_key }}"
## Prépare le répertoire de log
mkdir -p {{ restic_summary_log | dirname }}
## lancement de la sauvegarde
{{ restic_path }} backup --exclude-caches {% for i in restic_backup_excluded_path %} -e {{ i }} {% endfor %} {% for i in restic_backup_path %}{{ i }} {% endfor %}
{{ restic_path }} backup --quiet --json --exclude-caches {% for i in restic_backup_excluded_path %} -e {{ i }} {% endfor %} {% for i in restic_backup_path %}{{ i }} {% endfor %} > {{ restic_summary_log }}
## récupération de l'espace
{{ restic_path }} forget --prune {{ restic_backup_retention }}
{{ restic_path }} forget --quiet --prune {{ restic_backup_retention }}