Did you ever upload a website via FTP, scp, or even a clunky web uploader?
This can be quite cumbersome. Especially, when you forget to upload certain files and as a result, your website is broken. And doing this over and over again and trying very hard to make no mistakes can really break your spirit.
There must be a better way.
And there is! You can just sync the local directory where you keep the code of your website with rsync. This amazing tool will check each file and each subdirectory and make sure that the files that are on your server are in sync with the files on your computer. It can also delete all files that exist on the server but not on your local machine.
my-website/
├── css/
| ├── mobile.css
│ └── style.css
├── downloads/
| ├── download.zip
│ └── ...
├── fonts/
│ └── ...
├── js/
| ├── jquery.js
│ └── ...
├── images/
│ └── ...
├── index.php
├── about.php
├── ...
└── sync.sh
Let’s say we have a classic PHP website. You can then just add a sync.sh script at the root of your project directory:
Continue reading “How to Update Your Website with rsync”