restic formula rewrite and gitea updates

This commit is contained in:
Keiran Snowden
2023-11-26 21:56:18 -05:00
parent 0bb12fde34
commit 3de878dd20
13 changed files with 154 additions and 84 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/bash
source /opt/restic/env.sh
touch /var/log/restic/backup.log
chmod 600 /var/log/restic/backup.log
(
date
{{ '\n'.join(salt.pillar.get("restic:client:cmds")) | indent(2) }}
) 2>&1 | tee -a /var/log/restic/backup.log

View File

@@ -0,0 +1,4 @@
#!/bin/bash
{%- for var, val in salt.pillar.get("restic:client:environ").items() %}
export {{ var }}={{ val }}
{%- endfor %}

View File

@@ -0,0 +1,18 @@
#!/bin/bash
{% set arch = 'arm' salt.grains.get(cpuarch).startswith('arm') else 'amd64' %}
if test -z "$RESTIC_VERSION"; then
echo "RESTIC_VERSION is not defined"
exit 1
fi
URL="https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_{{ arch }}.bz2"
wget --quiet "${URL}" -O - | bzip2 -cd > /bin/restic.tmp
if [ $? -eq 0 ]; then
chmod +x /bin/restic.tmp
mv /bin/restic.tmp /bin/restic
else
rm -f /bin/restic.tmp
exit 1
fi

View File

@@ -1,12 +0,0 @@
#!/bin/sh
export HOME=/root
export RESTIC_PASSWORD={{ salt.pillar.get('restic:pass') }}
export RESTIC_REPOSITORY={{ salt.pillar.get('restic:repo') }}
restic backup --tag files {{ salt.pillar.get('restic:files') }}
{% if salt.pillar.get('restic:mysql', False) -%}
mysqldump --all-databases | restic backup --stdin --stdin-filename /all_databases.sql --tag mysql
{% endif -%}
restic forget --keep-last 4 --tag mysql --prune
{% if salt.pillar.get('restic:mysql', False) -%}
restic forget --keep-last 4 --tag files --prune
{% endif -%}