Efficiently Publish to a Website


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

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