updated borg state
This commit is contained in:
parent
015d25297f
commit
28e0ea4ab7
16
states/borg/config.sls
Normal file
16
states/borg/config.sls
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
{%- from "borg/map.jinja" import borg with context %}
|
||||
{% for key, job in borg.jobs.items() %}
|
||||
borg-config-script-{{ key }}:
|
||||
file.managed:
|
||||
- name: {{ borg.working_dir }}/scripts/borg_{{ key }}.sh
|
||||
- source: salt://borg/templates/borg_job.sh.j2
|
||||
- template: jinja
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 0755
|
||||
- context:
|
||||
key: {{ key }}
|
||||
job: {{ job }}
|
||||
working_dir: {{ borg.working_dir }}
|
||||
{% endfor %}
|
@ -2,5 +2,5 @@
|
||||
include:
|
||||
- .pkgs
|
||||
- .install
|
||||
#- .config
|
||||
- .config
|
||||
#- .schedule
|
||||
|
@ -1,19 +1,20 @@
|
||||
#!/bin/sh
|
||||
export MOUNTPOINT="{{ job.mountpoint }}"
|
||||
#!/bin/bash
|
||||
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||
|
||||
if [[ $(mountpoint -q $MOUNTPOINT) -eq 0 ]]
|
||||
export MOUNTPOINT="{{ job.mountpoint|default('/mnt') }}"
|
||||
|
||||
if [[ $(mountpoint -q $MOUNTPOINT) -ne 0 ]]
|
||||
then
|
||||
info "Mountpoint not exists, exiting backup"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
backup_name="{{ job.name }}"
|
||||
backup_name="{{ key }}"
|
||||
|
||||
export BORG_REPO=${MOUNTPOINT}/borg/${backup_name}
|
||||
export BORG_PASSPHRASE='{{ job.password }}'
|
||||
|
||||
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||
|
||||
info "Starting backup"
|
||||
|
||||
info "Init repository backup"
|
||||
@ -32,7 +33,7 @@ borg create \
|
||||
{% for include in job.included_dirs -%}
|
||||
{{ include }} \
|
||||
{% endfor -%}
|
||||
2>> /opt/borgbackup/logs/${backup_name}-$(date +%Y-%m-%d).log
|
||||
2>> {{ working_dir }}/logs/${backup_name}-$(date +%Y-%m-%d).log
|
||||
|
||||
backup_exit=$?
|
||||
|
||||
@ -51,13 +52,10 @@ global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
|
||||
|
||||
if [ ${global_exit} -eq 0 ]; then
|
||||
info "Backup and Prune finished successfully"
|
||||
#echo "Borg backup success for $backup_name job, proof file restore succeeded" | mutt -F {{ borgbackup_install_dir }}/.muttrc -s "BACKUP $backup_name SUCCESS" {{ job.value.notify_addr|default(borgbackup_mail_notify_addr) }}
|
||||
elif [ ${global_exit} -eq 1 ]; then
|
||||
info "Backup and/or Prune finished with warnings"
|
||||
#echo "Borg backup warning for $backup_name job, need for manual check of job for errors" | mutt -F {{ borgbackup_install_dir }}/.muttrc -s "BACKUP $backup_name WARNING" {{ job.value.notify_addr|default(borgbackup_mail_notify_addr) }}
|
||||
else
|
||||
info "Backup and/or Prune finished with errors"
|
||||
#echo "Borg backup failed for $backup_name job, need for manual check of job for errors" | mutt -F {{ borgbackup_install_dir }}/.muttrc -s "BACKUP $backup_name FAILED" {{ job.value.notify_addr|default(borgbackup_mail_notify_addr) }}
|
||||
fi
|
||||
|
||||
exit ${global_exit}
|
||||
|
Loading…
Reference in New Issue
Block a user