rsync example - ssh
This rsync example sends folder contents to a remote server using ssh. It also shows how to exclude multiple files or folders.
I recently switched to jekyll. And in that switch i created my own deploy-script using secure copy. It seemed to work well but I recently discovered that some of my files wasn’t being deployed at all. Not sure why, possibly because of a crappy folder exclude technique I was using. Knowing that many recommend rsync I decided to switch to it.This blog post explains the command I use to deploy my Jekyll site.
What is rsync? This is how the creators themselves explains it:
Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a large number of options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.
rsync ssh example that excludes multiple folders
What does those -avzuh -e options do?
-a, archive: it is the short alternative for all these options: rlptgoD
-v, verbose: Displays more information about what is happening when running the command.
-z, compress: Compresses the files during transfer.
-u, update: Skip files that haven’t changed.
-h, human readable: Output numbers in a human readable format.
-e, rsh: specify the remote shell to use.
--progress: Shows progress during the transfer.
--exclude: Folder or file to be excluded.
There are a lot more options to use.