What's the best deployment routine?

I so far didn’t master the “hugo deploy” - and used to tar.gz the public dir and scp it to my Apache VPS.
But my tar is 77Mb, where pictures are 75Mb and the rest is 2Mb.
So I attempted to leave the old pictures (they stay the same) and upload only the rest of the files throught the same procedure - tar, scp, untar.
I did, but the website did not start. I wonder what was the reason?
Maybe Hugo creates a sort of check and didn’t connect the pictures directory that was already there?

Is it possible to upload only certain files - or one should upload the whole website every time?

How hugo deploy works? Does it upload files one by one? I’m afraid it should take one hour compared to uploading a tar.gz file.

Have you tried using rsync?

I think there is no “best deployment routine”. It all depends on your project (Do you host your project on GitHub? What kind of server do you have?).

In my case I deploy locally and upload via rsync. It works fast and without problem. The problem with your routine is that you always have to upload the whole project whereas rsync automatically uploads only the changes. Let’s say you change one picture than rsync only changes one picture on your server.

1 Like

Wow, thank you @Troy, that’s a good idea! I will try it - that’s exactly what I want!
rsync works like a charm!

Here is my deploy script with rsync over ssh.

#!/usr/bin/env sh

hugo --cleanDestinationDir && rsync -e 'ssh -ax' --archive --delete --verbose --compress --human-readable --exclude '.DS_Store'

Thank you @frjo!

just be careful with --delete if you have any other files in the web directory. my site has stuff going back for 20 years, and I just rsync without --delete so none of the non-Hugo stuff gets nuked on publish. (my web directory is huge-ish so I don’t want to keep the whole thing locally on my laptop to rsync up)

1 Like

Good point about “–delete”!

Just a tiny addition:

rsync provides some practical short flags, see man rsync.

This is what I use:

rsync -aP source destination

-a stands for “archive”, -P comes in handy when you transfer some large files.

Thank you! :+1: