Rsync - Specifics

Modern technical writing - Andrew Etter 2016

Rsync
Specifics

Static site generators typically regenerate the entire site for even simple changes. This behavior helps ensure that the changes didn't have any unforeseen consequences and that the site will work properly. However, it also means that copying your new site onto an older version of the site (via FTP or SCP) can result in removed or renamed files not being overwritten and persisting on the server. The easy solution is to delete the old site from the server before copying over the new site, but a tool like Rsync can save you the hassle. Rsync transfers only the files that need to be added or updated, and it deletes stale files. Rsync is often used to keep staging and production servers in, well, sync.

If you use Windows, you probably need Cygwin to take advantage of Rsync. On macOS and Linux, installation and usage is more straightforward.

Note

If you use Amazon S3, the AWS Command Line Interface has a sync function that works similarly to Rsync.

A slightly more complicated alternative is to configure your production server as a remote repository and push the finished site to it, which accomplishes the same thing: new files get added, existing files get updated (if necessary), and stale files get deleted. Unsurprisingly, GitHub Pages uses this method.