Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # trap ctrl-c and call ctrl_c()
  2. trap ctrl_c INT
  3.  
  4. function ctrl_c() {
  5. exit
  6. }
  7.  
  8. # check if there are arguments
  9. if (( $# > 0 )); then
  10. # print the arguments, one per line
  11. printf "%s\n" "$@"
  12. else
  13. # there were no arguments, so run your original cat command
  14. cat /boot/scripts/backup_locations.txt
  15. fi | while read myMount
  16. do
  17.  
  18. MOUNT_PATH="/mnt/storage_$myMount"
  19. LOCAL_PATH="/mnt/user/$myMount"
  20.  
  21. if [ ! -d "$MOUNT_PATH" ]
  22. then
  23. echo "####################"
  24. echo mkdir "$MOUNT_PATH"
  25. mkdir "$MOUNT_PATH"
  26.  
  27. echo mount -t nfs 192.168.2.3:"$LOCAL_PATH" "$MOUNT_PATH"
  28. mount -t nfs 192.168.2.3:"$LOCAL_PATH" "$MOUNT_PATH"
  29. # mount -t cifs -o user=nobody,password=nobody,vers=2.1 //192.168.2.3/$myMount "$MOUNT_PATH"
  30.  
  31. if cut -d' ' -f2 /proc/mounts | grep '^'"$MOUNT_PATH"'$' >/dev/null; then
  32. sleep 1
  33. echo rsync -av --delete-after --progress --exclude-from='/boot/scripts/excludes.txt' "$MOUNT_PATH"/ "$LOCAL_PATH"
  34. rsync -av --delete-after --progress --exclude-from='/boot/scripts/excludes.txt' "$MOUNT_PATH"/ "$LOCAL_PATH"
  35.  
  36. echo umount "$MOUNT_PATH"
  37. umount "$MOUNT_PATH"
  38.  
  39. fi
  40.  
  41. echo rmdir "$MOUNT_PATH"
  42. rmdir "$MOUNT_PATH"
  43.  
  44. echo "####################"
  45. fi
  46.  
  47. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement