Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- MAIN_REPO="/volume1/Restic-Main/restic-repository/"
- MAIN_PASSWORD="..."
- SECONDARY1_REPO="/volume1/Restic-secondary1/restic-repository/"
- SECONDARY1_PASSWORD="...."
- SECONDARY2_REPO="/volume1/Restic-secondary2/restic-repository/"
- SECONDARY2_PASSWORD="..."
- function backupNAS {
- export RESTIC_REPOSITORY="${MAIN_REPO}"
- export RESTIC_PASSWORD="${MAIN_PASSWORD}"
- ./restic backup --retry-lock 1m /volume1/ --no-scan --exclude-caches --exclude-file .restic-exclude-file
- export RESTIC_REPOSITORY=""
- export RESTIC_PASSWORD=""
- }
- function forgetMainRepo {
- export RESTIC_REPOSITORY="${MAIN_REPO}"
- export RESTIC_PASSWORD="${MAIN_PASSWORD}"
- ./restic forget --retry-lock 1m --compact --keep-within 14d --keep-within-hourly 30d --keep-within-daily 100d --keep-within-weekly 365d --keep-monthly unlimited
- export RESTIC_REPOSITORY=""
- export RESTIC_PASSWORD=""
- }
- function copyToMainRepo {
- export RESTIC_REPOSITORY="${MAIN_REPO}"
- export RESTIC_PASSWORD="${MAIN_PASSWORD}"
- export RESTIC_FROM_REPOSITORY="${1}"
- export RESTIC_FROM_PASSWORD="${2}"
- ./restic copy --retry-lock 1m
- export RESTIC_REPOSITORY=""
- export RESTIC_PASSWORD=""
- export RESTIC_FROM_REPOSITORY=""
- export RESTIC_FROM_PASSWORD=""
- }
- function forgetRemoteRepo {
- export RESTIC_REPOSITORY="${1}"
- export RESTIC_PASSWORD="${2}"
- ./restic forget --prune --keep-last 10 --compact --retry-lock 1m
- export RESTIC_REPOSITORY=""
- export RESTIC_PASSWORD=""
- }
- function removeStaleLocks {
- export RESTIC_REPOSITORY="${1}"
- export RESTIC_PASSWORD="${2}"
- ./restic unlock
- export RESTIC_REPOSITORY=""
- export RESTIC_PASSWORD=""
- }
- export GOMEMLIMIT=800MiB
- export RESTIC_CACHE_DIR=/volume1/Backups/.cache/restic
- removeStaleLocks "${MAIN_REPO}" "${MAIN_PASSWORD}"
- backupNAS
- removeStaleLocks "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
- copyToMainRepo "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
- removeStaleLocks "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
- copyToMainRepo "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
- forgetRemoteRepo "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
- forgetRemoteRepo "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
- forgetMainRepo
- ./restic cache --cleanup --max-age 28
- ./restic self-update
Advertisement
Add Comment
Please, Sign In to add comment