#!/bin/bash

sudo /usr/local/bin/restic self-update
sudo setcap cap_dac_read_search=+ep /usr/local/bin/restic

MACHINE=bubonic
ZONE=root

export RESTIC_REPOSITORY=
export RESTIC_PASSWORD=

/usr/local/bin/restic backup -v \
    --tag $MACHINE --tag $ZONE \
    / \
    --exclude=/dev \
    --exclude=/run \
    --exclude=/tank \
    --exclude=/scratch \
    --exclude=/proc \
    --exclude=/sys \
    --exclude=/var/lib/docker \
    --exclude=/var/lib/lxcfs \
    --exclude=/var/lib/containers \
    --exclude=/mnt \
    --exclude=/var/run \
    --exclude=/tmp \
    --exclude=/var/tmp

/usr/local/bin/restic forget -v \
    --tag $MACHINE --tag $ZONE \
    --keep-daily=7 \
    --keep-weekly=4 \
    --keep-monthly=12 \
    --keep-yearly 1

# This can take a very, very long time
/usr/local/bin/restic prune && /usr/local/bin/restic check
