I want to reduce this script in Bash. All it does is upload files via rsync.
#!/bin/bash
# Remote address
[email protected]
# Upload mytheme
rsync -azvP -e 'ssh -p 1234' --delete --exclude=.git --exclude=node_modules /usr/local/var/www/example.com/wp-content/themes/mytheme/ $REMOTE_ADDRESS:/home/user1/htdocs/example1.com/wp-content/themes/mytheme/
# Upload the other theme
rsync -azvP -e 'ssh -p 1234' --delete --exclude=.git --exclude=node_modules /usr/local/var/www/example.com/wp-content/themes/this-is-another-theme/ $REMOTE_ADDRESS:/home/admin/domains/example2.com/public_html/wp-content/themes/this-is-another-theme/
What would be the best way?
I tried with
RSYNC_CMD="rsync -azvP -e 'ssh -p 1234' --delete --exclude=.git --exclude=node_modules"
# Upload mytheme
$RSYNC_CMD /usr/local/var/www/example.com/wp-content/themes/this-is-another-theme/ $REMOTE_ADDRESS:/home/user1/htdocs/example1.com/wp-content/themes/mytheme/ --dry-run
But it doesn’t work. Terminal says:
Missing trailing-’ in remote-shell command.
rsync error: syntax or usage error (code 1) at /AppleInternal/Library/BuildRoots/810eba08-405a-11ed-86e9-6af958a02716/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(352) [sender=2.6.9]
Hopefully you are a pro writing bash scripts