Advertisement
lswest

borg-backup

Feb 9th, 2017
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. REPOSITORY=user@IP:/path/to/share
  4. TARGET="/mount/point"
  5.  
  6. export BORG_PASSPHRASE="PASSPHRASE"
  7.  
  8. hostname=$(hostname)
  9. date=$(date +%Y-%m-%d)
  10.  
  11. echo "Mounting..."
  12. sshfs $REPOSITORY $TARGET
  13.  
  14. if [ "$1" == "-p" ]; then
  15.     echo "Creating..."
  16.     borg create -v --progress --stats --compression zlib,9 $TARGET::$hostname-$date $HOME --exclude '/home/*/.cache' --exclude '/home/*/.btsync'
  17. else
  18.     echo "Creating..."
  19.     borg create -v --stats --compression zlib,9 $TARGET::$hostname-$date $HOME --exclude '/home/*/.cache' --exclude '/home/*/.btsync'
  20. fi
  21. echo "Pruning..."
  22. borg prune -v $TARGET --prefix $hostname- --keep-daily=7 --keep-weekly=4 --keep-monthly=6
  23.  
  24. echo "Unmounting..."
  25. sleep 10; fusermount -u $TARGET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement