Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # trap ctrl-c and call ctrl_c()
- trap ctrl_c INT
- function ctrl_c() {
- exit
- }
- # check if there are arguments
- if (( $# > 0 )); then
- # print the arguments, one per line
- printf "%s\n" "$@"
- else
- # there were no arguments, so run your original cat command
- cat /boot/scripts/backup_locations.txt
- fi | while read myMount
- do
- MOUNT_PATH="/mnt/storage_$myMount"
- LOCAL_PATH="/mnt/user/$myMount"
- if [ ! -d "$MOUNT_PATH" ]
- then
- echo "####################"
- echo mkdir "$MOUNT_PATH"
- mkdir "$MOUNT_PATH"
- echo mount -t nfs 192.168.2.3:"$LOCAL_PATH" "$MOUNT_PATH"
- mount -t nfs 192.168.2.3:"$LOCAL_PATH" "$MOUNT_PATH"
- # mount -t cifs -o user=nobody,password=nobody,vers=2.1 //192.168.2.3/$myMount "$MOUNT_PATH"
- if cut -d' ' -f2 /proc/mounts | grep '^'"$MOUNT_PATH"'$' >/dev/null; then
- sleep 1
- echo rsync -av --delete-after --progress --exclude-from='/boot/scripts/excludes.txt' "$MOUNT_PATH"/ "$LOCAL_PATH"
- rsync -av --delete-after --progress --exclude-from='/boot/scripts/excludes.txt' "$MOUNT_PATH"/ "$LOCAL_PATH"
- echo umount "$MOUNT_PATH"
- umount "$MOUNT_PATH"
- fi
- echo rmdir "$MOUNT_PATH"
- rmdir "$MOUNT_PATH"
- echo "####################"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement