restic formula rewrite and gitea updates
This commit is contained in:
8
restic/files/backup.sh.jinja
Normal file
8
restic/files/backup.sh.jinja
Normal 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
|
||||
4
restic/files/env.sh.jinja
Normal file
4
restic/files/env.sh.jinja
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
{%- for var, val in salt.pillar.get("restic:client:environ").items() %}
|
||||
export {{ var }}={{ val }}
|
||||
{%- endfor %}
|
||||
18
restic/files/install.sh.jinja
Normal file
18
restic/files/install.sh.jinja
Normal 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
|
||||
@@ -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 -%}
|
||||
Reference in New Issue
Block a user