Advertisement
TringaliLuca

Automatic backup with rsync and SSHFS

Mar 21st, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #please edit folder paths to fill your needs
  4. origin="/home/luca/"
  5. destination="/media/luca/MYDISK/backup-luca/"
  6. mountpoint="/media/luca/MYDISK"
  7.  
  8. if pgrep "rsync" > /dev/null
  9. then
  10.     echo "There is already rsync running"
  11.     exit 0
  12. fi
  13.  
  14. if [ ! -d "$destination" ]; then
  15.     #your password is stored without encryption. This is not safe.
  16.     echo "lamiapassword" | sshfs utente@server.lan:/ "$mountpoint" -o password_stdin
  17. fi
  18.  
  19. if [ -d "$destination" ]; then
  20.     rsync -avr --progress  --delete --no-perms --omit-dir-times "$origin" "$destination"
  21.     dpkg --get-selections > "$destination/pacchetti_installati.txt"
  22.     umount "$mountpoint"
  23. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement