

Rsync -avz -delete $BASEPATH/upload/ would be possible to directly perform the synchronization between the local public/ directory and the remote server using the checksum method.

Rsync -r -delete -checksum $BASEPATH/public/ $BASEPATH/upload/ Also, rsync provides the ability to synchronize a directory structure (or even a single file. It checks to see if files exist in the destination before sending them, saving bandwidth and time for everything it skips.
#Rsync checksum update#
The following sync.sh bash script does all the work: #!/bin/bashīASEPATH=/your-path-to-local-hugo-base-directory/ The rsync tool can recursively navigate a directory structure and update a second location with any new/changed/removed files. In this way, the files in the upload/ directory are updated only when there is an actual change in the content within the public/ directory.Īfterwards, I can use the usual remote synchronization method between the local upload/ directory and the remote server using the modification times. The synchronization is not done by modification date, but by file checksum, which is one of the methods provided by rsync. At the end of every upload or download, the gsutil rsync command validates that the checksum of the source file/object. The upload/ directory is kept synchronized with the Hugo’s public/ directory. Checksum Validation And Failure Handling. I have a local directory called upload/, which is located in the same Hugo base directory. To limit this problem, I use this workaround. erty that it is very cheap to calculate the checksum of a. This happens because Hugo regenerates all the files at every local build.įor this reason, when rsync checks the changes in the modification times between local and remote files, the local ones are all always newer, and thus all of them are uploaded remotely. The weak rolling checksum used in the rsync algorithm needs to have the prop. Three blocks in the new file matched blocks in the old file. RSync: Halfway through detecting the differences between the new and the old version of the file. This option changes this to compare a 128- bit checksum for each file with a matching size. RSync: Block checkums for old file received, and rolling checksum match in new file now begins. Without this option, rsync uses a 'quick check' that (by default) checks if each file's size and time of last modification match between the sender and receiver. In particular, everytime I rebuild the local copy of the site with Hugo, and I run the command to synchronize the remote copy, all the local files are uploaded to the server. This changes the way rsync checks if the files were changed and are in need of a transfer. The rolling checksum used in rsync is based on Mark Adlers adler-32. After having moved to Hugo for my personal website, I found that the usual way of using rsync to update the copy of the website on the remote server does not work efficiently. rsync is a utility for efficiently transferring and synchronizing files between a computer.
