Recently I’ve found a blazing fast way to move/copy a website from one location to another. It’s so fast that literally you can copy an entire site to another directory or host while you are stretching your neck for a moment!
Key to this process is using a Linux utility called rsync.
Before you begin you should know:
- This is a bit technical and some prior knowledge of SSH is recommended.
- This will only work on or between Linux servers with rsync. But from my experience, rsync is usually installed on most popular hosting companies because they use it for back up/migration purposes.
- Also, this will not move your database so that needs to be dealt with separately.
- And just as a precaution, you also might want to back up your important files first.
Here are the exact steps that we take:
1) Launch PuTTY and Enter IP address of the old server or domain account and click “open”
2) Login with our root password. Hint: right click is equivalent of Control + v (paste)
3) Run “rsync -help” (without double quotes) to make sure it’s installed and running
4) Send the following command line replacing certain info
rsync -vpzrt –stats –links –progress -e ssh –exclude “*bak” –exclude “*~” –exclude “cgi-bin” –exclude “error_log” –exclude “.ftpquota” –exclude “php.ini” /home/username_from/public_html/* username_to@ip_address:/home/username_to/public_html/
- Replace /home/username_from/public_html/ with an system absolute path of a site directory we are copying from.
- Replace username_to with a FTP username of a new site we are copying to.
- Replace ip_address to the new site’s IP address
- Make sure /home/username_to/public_html/ part is also a system absolute path to the new site directory.
5) Verify that files are copied as you wanted and you’re done!
You should be aware that this command line will not copy .htaccess, php.ini since we might want to deal with that separately because a new hosts’ setting can vary.
If you are tackling this for the first time, I recommend testing with one file as oppose to an entire directly. In that case you just change /public_html/* to /public_html/filename.txt and make sure it’s created in the new directory.
I found these tutorial resources useful:
Hope this helps for web developers out there!