Guest User

Untitled

a guest
Feb 1st, 2025
23
0
8 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.25 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. MAIN_REPO="/volume1/Restic-Main/restic-repository/"
  4. MAIN_PASSWORD="..."
  5. SECONDARY1_REPO="/volume1/Restic-secondary1/restic-repository/"
  6. SECONDARY1_PASSWORD="...."
  7. SECONDARY2_REPO="/volume1/Restic-secondary2/restic-repository/"
  8. SECONDARY2_PASSWORD="..."
  9.  
  10.  
  11. function backupNAS {
  12.     export RESTIC_REPOSITORY="${MAIN_REPO}"
  13.     export RESTIC_PASSWORD="${MAIN_PASSWORD}"
  14.    
  15.     ./restic backup --retry-lock 1m /volume1/ --no-scan --exclude-caches --exclude-file .restic-exclude-file
  16.    
  17.     export RESTIC_REPOSITORY=""
  18.     export RESTIC_PASSWORD=""
  19. }
  20.  
  21.  
  22. function forgetMainRepo {
  23.     export RESTIC_REPOSITORY="${MAIN_REPO}"
  24.     export RESTIC_PASSWORD="${MAIN_PASSWORD}"
  25.    
  26.     ./restic forget --retry-lock 1m --compact --keep-within 14d --keep-within-hourly 30d --keep-within-daily 100d --keep-within-weekly 365d --keep-monthly unlimited
  27.    
  28.     export RESTIC_REPOSITORY=""
  29.     export RESTIC_PASSWORD=""
  30. }
  31.  
  32.  
  33. function copyToMainRepo {
  34.     export RESTIC_REPOSITORY="${MAIN_REPO}"
  35.     export RESTIC_PASSWORD="${MAIN_PASSWORD}"
  36.     export RESTIC_FROM_REPOSITORY="${1}"
  37.     export RESTIC_FROM_PASSWORD="${2}"
  38.    
  39.     ./restic copy --retry-lock 1m
  40.    
  41.     export RESTIC_REPOSITORY=""
  42.     export RESTIC_PASSWORD=""
  43.     export RESTIC_FROM_REPOSITORY=""
  44.     export RESTIC_FROM_PASSWORD=""
  45. }
  46.  
  47.  
  48. function forgetRemoteRepo {
  49.     export RESTIC_REPOSITORY="${1}"
  50.     export RESTIC_PASSWORD="${2}"
  51.    
  52.     ./restic forget --prune --keep-last 10 --compact --retry-lock 1m
  53.    
  54.     export RESTIC_REPOSITORY=""
  55.     export RESTIC_PASSWORD=""
  56. }
  57.  
  58.  
  59. function removeStaleLocks {
  60.     export RESTIC_REPOSITORY="${1}"
  61.     export RESTIC_PASSWORD="${2}"
  62.    
  63.     ./restic unlock
  64.    
  65.     export RESTIC_REPOSITORY=""
  66.     export RESTIC_PASSWORD=""
  67. }
  68.  
  69.  
  70. export GOMEMLIMIT=800MiB
  71. export RESTIC_CACHE_DIR=/volume1/Backups/.cache/restic
  72.  
  73. removeStaleLocks "${MAIN_REPO}" "${MAIN_PASSWORD}"
  74.  
  75. backupNAS
  76.  
  77. removeStaleLocks "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
  78. copyToMainRepo   "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
  79.  
  80. removeStaleLocks "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
  81. copyToMainRepo   "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
  82.  
  83. forgetRemoteRepo "${SECONDARY1_REPO}" "${SECONDARY1_PASSWORD}"
  84. forgetRemoteRepo "${SECONDARY2_REPO}" "${SECONDARY2_PASSWORD}"
  85. forgetMainRepo
  86.  
  87. ./restic cache --cleanup --max-age 28
  88. ./restic self-update
  89.  
Advertisement
Add Comment
Please, Sign In to add comment