backup.sh 668 Bytes
Newer Older
kaiyou's avatar
kaiyou committed
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env bash

set -e -o pipefail

source /srv/config/backup.config
export RESTIC_REPOSITORY RESTIC_PASSWORD AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY

restic backup \
        --verbose \
        --one-file-system \
kaiyou's avatar
kaiyou committed
11
        --exclude-if-present .nobackup \
12
        ${*:-$(find $BACKUP_PATHS -maxdepth 1 -mindepth 1 -type d)} &
kaiyou's avatar
kaiyou committed
13 14 15 16 17 18
wait $!

restic forget \
        --verbose \
        --prune \
        --group-by "paths" \
kaiyou's avatar
kaiyou committed
19
        --keep-last $RETENTION_LASTS \
kaiyou's avatar
kaiyou committed
20 21 22 23 24 25 26
        --keep-daily $RETENTION_DAYS \
        --keep-weekly $RETENTION_WEEKS \
        --keep-monthly $RETENTION_MONTHS \
        --keep-yearly $RETENTION_YEARS &
wait $!

echo "Backup & cleaning is done."