Skip to content

Instantly share code, notes, and snippets.

@lucarin91
Last active December 20, 2022 14:09
Show Gist options
  • Save lucarin91/294bb88c395df63ca6a768201a9e26c9 to your computer and use it in GitHub Desktop.
Save lucarin91/294bb88c395df63ca6a768201a9e26c9 to your computer and use it in GitHub Desktop.
Synchronize a local folder with a remote server in a bidirectional way.
#!/bin/sh
set -e
### Configuration ###
[email protected]
REMOTE_FOLDER=my_folder
REMOTE_RESULTS=results
EXCLUDE_FILES="--exclude=.*\
--exclude=build/"
### Remote syncronization ###
set -x
# Push code to the remote server
rsync -avz --delete $EXCLUDE_FILES --exclude=$REMOTE_RESULTS . "$SERVER:$REMOTE_FOLDER"
# Pull results from the remote server
rsync -avz "$SERVER:$REMOTE_FOLDER/$REMOTE_RESULTS" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment