2022-11-03 08:35:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
{%- if pillar.restic.repository is defined %}
|
|
|
|
export RESTIC_REPOSITORY={{ pillar.restic.mount }}{{ pillar.restic.suffix }}
|
|
|
|
{%- else %}
|
|
|
|
export RESTIC_REPOSITORY="stfp:{{ pillar.restic.user }}@{{ pillar.restic.host }}:{{ pillar.restic.mount }}{{ pillar.restic.suffix }}"
|
|
|
|
{%- endif %}
|
|
|
|
export RESTIC_PASSWORD={{ pillar.restic.password }}
|
|
|
|
|
2022-12-01 08:08:53 +00:00
|
|
|
GOTIFY_URL="{{ pillar.restic.gotify.url }}"
|
|
|
|
GOTIFY_TOKEN="{{ pillar.restic.gotify.token }}"
|
|
|
|
GOTIFY_PRIO="5"
|
|
|
|
GOTIFY_TITLE="backup on $HOSTNAME"
|
|
|
|
|
2022-11-03 08:35:40 +00:00
|
|
|
restic backup \
|
|
|
|
--exclude="*.tmp" \
|
|
|
|
--exclude="lost+found" \
|
|
|
|
--exclude="Cache" \
|
|
|
|
--exclude="cache" \
|
|
|
|
--exclude=".cache" \
|
|
|
|
--exclude="tmp" \
|
|
|
|
--exclude="temp" \
|
|
|
|
--exclude="Temp" \
|
|
|
|
--exclude="/home/*/go" \
|
|
|
|
--exclude="/home/*/.local/share/virtualenv" \
|
|
|
|
--exclude="/home/*/.local/share/virtualenvs" \
|
|
|
|
--exclude="/home/*/VirtualBox VMs" \
|
|
|
|
--exclude="/home/*/.mozillla/firefox/*/minidumps" \
|
|
|
|
--exclude="/home/*/.mozillla/firefox/*/storage" \
|
|
|
|
--exclude="/home/*/.mozillla/firefox/*/extensions.sqlite" \
|
|
|
|
--exclude="/home/*/.mozillla/firefox/*/urlclassifier3.sqlite" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/Local Storage" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/Session Storage" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/Application Cache" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/History" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/History-journal" \
|
|
|
|
--exclude="/home/*/.config/google-chrome/*/History Provider Cache" \
|
|
|
|
--exclude="/home/*/.local/share/flatpak" \
|
|
|
|
--exclude="/home/*/.var/app/com.slack.Slack" \
|
|
|
|
--exclude="/home/*/.local/share/Trash" \
|
|
|
|
--exclude="/home/*/.config/Microsoft/Microsoft Teams" \
|
|
|
|
--exclude="/home/*/.wine" \
|
|
|
|
--exclude="/home/*/.vim/bundle" \
|
|
|
|
--exclude="/home/*/snap" \
|
|
|
|
--exclude="/home/*/Downloads" \
|
|
|
|
--exclude="/home/*/Nextcloud" \
|
|
|
|
--exclude="/home/*/git" \
|
|
|
|
--verbose \
|
2022-11-04 08:10:35 +00:00
|
|
|
{%- if pillar.podman is defined %}
|
|
|
|
{{ salt['cmd.run']('podman info -f "{{.Store.VolumePath}}"', runas=pillar.podman.user ) }} \
|
|
|
|
{%- endif %}
|
|
|
|
{%- if pillar.containers.mariadb is defined %}
|
|
|
|
{{ pillar.containers.mariadb.backup_dir }} \
|
|
|
|
{%- endif %}
|
2022-11-03 08:39:32 +00:00
|
|
|
/etc \
|
2022-11-03 12:27:06 +00:00
|
|
|
/root \
|
2022-11-03 08:35:40 +00:00
|
|
|
/home
|
2022-12-01 08:08:53 +00:00
|
|
|
|
|
|
|
return_code="$?"
|
|
|
|
if [[ "$return_code" == "0" ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
MESSAGE="$(journalctl -u restic-backup.service -p 5 --since today)"
|
|
|
|
curl "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" -F "title=$GOTIFY_TITLE" -F "priority=$GOTIFY_PRIO" -F "message=$MESSAGE"
|