Refine our simple deployment method using rsync instead of scp.Our local
deploy.sh script is currently using secure copy:
#!/usr/bin/env bash scp ./* deploy-ex:/var/www/site
Let's update this to use rsync over scp:
#!/usr/bin/env bash rsync -vzcrSLhp --exclude="deploy.sh" ./ deploy-ex:/var/www/site # The options: # v - verbose # z - compress data # c - checksum, use checksum to find file differences # r - recursive # S - handle sparse files efficiently # L - follow links to copy actual files # h - show numbers in human-readable format # p - keep local file permissions (not necessarily recommended) # --exclude - Exclude files from being uploaded
We get an error, saying it can't change permissions. We rectify this by removing the
-p flag, as the local permissions are different than what we want on the remote server. The user "deployer" happens to not have permissions to change the target directory permissions.
We make a change to
index.html locally to ensure it gets uploaded and re-run the bash script:
See that only changed files are uploaded.