SHARE
TWEET

Automatic backup with rsync and SSHFS

TringaliLuca Mar 21st, 2017 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top