I used to run the following commands to upload files to this website:
scp file1 file2 user@host: scp articles/file3 user@host:/home/public/articles
Typing out the path of the host is tedious, so rsync can be used. This command can be added to .git/hooks/pre-push to run on git push.
rsync -rtzP --delete --exclude="*git" ~/website/ user@host:/home/public
- -r: recursively
- -t: transfer modification times, allowing unmodified files to be skipped
- -z: compress files for uploading
- -P: if a large file fails to be uploaded, continue from where it was instead of uploading its entirety
- --delete: delete files from the receiving side that aren't locally present
- --exclude="*git": exclude this pattern from uploading and following rules like --delete
The slash after the folder name is there for uploading the contents of the folder and not the folder itself. Without the slash, it would result in /home/public/website.
I wrote the following in .ssh/config, allowing me to run ssh riazj or rsync file riazj:.
Host riazj Hostname nfsnssh.com User riazpy_riazj Port 22