Advertisement
Guest User

Restic Backup Script

a guest
Feb 4th, 2018
1,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. #set backblaze b2 accout credentials
  4. export B2_ACCOUNT_ID="b2AccountID"
  5. export B2_ACCOUNT_KEY="b2AccountKey"
  6. export RESTIC_PASSWORD="resticRepoPassword"
  7.  
  8. #set restic bucket repo
  9. export RESTIC_REPOSITORY="b2:resticRepo"
  10.  
  11. #backup Home directory excluding any unwanted directories
  12. #script will not backup Downloads
  13. #script backs all home directory
  14. restic backup --exclude=~/Downloads ~
  15.  
  16.  
  17. #check data is correctly in repo
  18. #
  19. restic check >> /file/to/write/log.txt
  20. restic snapshots >> /file/to/write/log.txt
  21.  
  22. #Remove old repos based on backup strategy
  23. restic forget       \
  24. --keep-hourly 4     \
  25. --keep-daily 7      \
  26. --keep-weekly 4     \
  27. --keep-monthly 6    \
  28. >> /file/to/write/log.txt
  29.  
  30. #Delete removed snapshots
  31. restic prune >> /file/to/write/log.txt
  32.  
  33.  
  34. #Route the normal process logging to journalctl
  35. 2>&1
  36.  
  37. #reset b2 credentials
  38. export B2_ACCOUNT_ID =""
  39. export B2_ACCOUNT_KEY=""
  40. export RESTIC_PASSWORD=""
  41.  
  42. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement