Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Define the source and remote paths
- SOURCE="/local/path/to/PSP/SAVEDATA/"
- REMOTE_HOST="SSH-HostName"
- REMOTE_PATH="/remote/path/to/RetroArch/psp/"
- LOCAL_MOUNT_POINT="/local/sshfs/path/for/temp/use"
- # Prompt the user to select sync direction
- echo "Select sync direction:"
- echo "1. Mirror PSP to Raspberry Pi"
- echo "2. Mirror Raspberry Pi to PSP"
- read -p "Enter your choice (1 or 2): " choice
- # Validate the choice
- if [[ "$choice" != "1" && "$choice" != "2" ]]; then
- echo "Invalid choice. Exiting..."
- exit 1
- fi
- # Mount the remote directory using sshfs
- echo "Mounting remote directory $REMOTE_HOST:$REMOTE_PATH to $LOCAL_MOUNT_POINT..."
- sshfs $REMOTE_HOST:$REMOTE_PATH $LOCAL_MOUNT_POINT
- if [ $? -ne 0 ]; then
- echo "Failed to mount remote directory. Exiting..."
- exit 1
- fi
- # Function to mirror contents with exclusions
- mirror_contents() {
- local src="$1"
- local dest="$2"
- echo "Mirroring contents of $src to $dest..."
- rsync -av --delete --inplace --no-perms --exclude=".stfolder" --exclude=".syncthing.*" "$src" "$dest"
- }
- # Perform mirroring based on user choice
- if [ "$choice" == "1" ]; then
- echo "You chose to mirror PSP to Raspberry Pi."
- mirror_contents "$SOURCE" "$LOCAL_MOUNT_POINT"
- elif [ "$choice" == "2" ]; then
- echo "You chose to mirror Raspberry Pi to PSP."
- mirror_contents "$LOCAL_MOUNT_POINT" "$SOURCE"
- fi
- # Unmount the remote directory after mirroring is completed
- echo "Unmounting remote directory..."
- fusermount -u $LOCAL_MOUNT_POINT
- if [ $? -eq 0 ]; then
- echo "Remote directory unmounted successfully."
- else
- echo "Failed to unmount remote directory."
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment