Compare commits

...

3 Commits

9 changed files with 31 additions and 12 deletions

View File

@ -135,7 +135,7 @@ sudo_rules:
restic_repos: restic_repos:
- name: b2 - name: b2
repo: "b2:kill0-infra-backup:" repo: "b2:kill0-infra-backup:/{{ inventory_hostname_short }}"
environment: environment:
RESTIC_PASSWORD: "{{ vault_restic_repo_b2_password }}" RESTIC_PASSWORD: "{{ vault_restic_repo_b2_password }}"
B2_ACCOUNT_ID: "{{ vault_restic_repo_b2_account_id }}" B2_ACCOUNT_ID: "{{ vault_restic_repo_b2_account_id }}"

View File

@ -6,8 +6,6 @@
- util - util
- sudo - sudo
- hostsfile - hostsfile
- { role: vm_guest, when: "ansible_virtualization_type is defined" }
- grub
- certs - certs
- rsyslog - rsyslog
- users - users
@ -19,8 +17,6 @@
- chrony - chrony
- unattended-upgrades - unattended-upgrades
- postfix - postfix
- aide
- telegraf
- restic - restic
- node_exporter - node_exporter
- blackbox_exporter - blackbox_exporter

View File

View File

View File

View File

@ -33,7 +33,7 @@ main() {
gitea dump \ gitea dump \
--config "$GITEA_CONFIG" \ --config "$GITEA_CONFIG" \
--work-path "$GITEA_WORK_PATH" \ --work-path "$GITEA_WORK_PATH" \
--custom-path "$GITEA_CUSTOM_PATH" > /dev/null --custom-path "$GITEA_CUSTOM_PATH" >/dev/null 2>&1
printf "gitea dump complete\n" printf "gitea dump complete\n"
popd > /dev/null || printf "could not chdir to %s\n" "$OLDPWD" popd > /dev/null || printf "could not chdir to %s\n" "$OLDPWD"
elif [ "$1" == "post" ]; then elif [ "$1" == "post" ]; then

View File

@ -19,8 +19,14 @@ NICE="ionice -c2 nice -n19"
JOB=$1 JOB=$1
LOCK="/run/restic/${JOB}.lock" LOCK="/run/restic/${JOB}.lock"
KEEP_HOURLY=${KEEP_HOURLY:-24}
KEEP_DAILY=${KEEP_DAILY:-7}
KEEP_WEEKLY=${KEEP_WEEKLY:-5}
KEEP_MONTHLY=${KEEP_MONTHLY:-12}
KEEP_YEARLY=${KEEP_YEARLY:-10}
function finish { function finish {
if [ -z $KEEP_LOCK ]; then if [ -z "$KEEP_LOCK" ]; then
rm -f "$LOCK" rm -f "$LOCK"
fi fi
} }
@ -90,6 +96,25 @@ echo $$ > "$LOCK"
LOCKED=$(($(date +%s) - START)) LOCKED=$(($(date +%s) - START))
printf "prune: started, keep hourly:%d daily:%d weekly:%d monthly:%d year:%d\n" \
"$KEEP_HOURLY" \
"$KEEP_DAILY" \
"$KEEP_WEEKLY" \
"$KEEP_MONTHLY" \
"$KEEP_YEARLY"
$RESTIC_PATH forget \
--quiet \
--host "$(hostname -f)" \
--keep-hourly "$KEEP_HOURLY" \
--keep-daily "$KEEP_DAILY" \
--keep-weekly "$KEEP_WEEKLY" \
--keep-monthly "$KEEP_MONTHLY" \
--keep-yearly "$KEEP_YEARLY" \
--prune
printf "prune: complete\n"
printf "job '%s' started\n" "$JOB" printf "job '%s' started\n" "$JOB"
if [ -d "${HOOKS_PATH}" ]; then if [ -d "${HOOKS_PATH}" ]; then
@ -127,7 +152,7 @@ until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
done done
printf "restic complete\n" printf "restic complete\n"
if [ $rc -ne 0 ] && [ $counter -eq "$MAX_ATTEMPTS" ]; then if [ $rc -ne 0 ] && [ "$counter" -eq "$MAX_ATTEMPTS" ]; then
printf "restic job timed out, exiting\n" printf "restic job timed out, exiting\n"
else else
printf "job '%s' complete\n" "$JOB" printf "job '%s' complete\n" "$JOB"

View File

@ -13,7 +13,7 @@ LOCK="${LOCK_PATH}/tidy.lock"
KEEP_LOCK= KEEP_LOCK=
function finish { function finish {
if [ -z $KEEP_LOCK ]; then if [ -z "$KEEP_LOCK" ]; then
rm -f "$LOCK" rm -f "$LOCK"
fi fi
} }
@ -109,7 +109,7 @@ until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
(( counter++ )) (( counter++ ))
done done
if [ $rc -ne 0 ] && [ $counter -eq "$MAX_ATTEMPTS" ]; then if [ $rc -ne 0 ] && [ "$counter" -eq "$MAX_ATTEMPTS" ]; then
printf "tidy timed out, exiting\n" printf "tidy timed out, exiting\n"
else else
printf "complete\n" printf "complete\n"

View File

@ -111,8 +111,6 @@
network_config: network_config:
address: 172.17.10.53/24 address: 172.17.10.53/24
gateway: 172.17.10.1 gateway: 172.17.10.1
roles:
- libvirt
- hosts: rabbitmq_servers - hosts: rabbitmq_servers
become: true become: true
vars: vars: