Home / Software / How to Sync Two Websites on the Same Server

How to Sync Two Websites on the Same Server

network sharing iconQuestion: I have two separate websites that I want to have identical data on each site. How can I do this?

Answer: First of all, to sync files on two separate sites on the same server, you will need to have a user that has write permissions on both sites. If you are using a shared hosting account, and both sites are under your account, you probably already have this. For a VPS that has a unique user for each site, you will need to use the root user.

Next, you need to know the full path to the directories for both sites. For example, site one may be /home/user/www/html/siteone.com/html and site two may be /home/user/www/html/sitetwo.com/html. To sync both directories and keep them synced even when data changes, the best choice is rsync. Although rsync is normally used for remote syncing, it also works for local directories.

To sync the two directories, you would use this command:

rsync -avc /home/user/www/html/siteone.com/html/ /home/user/www/html/sitetwo.com/html/

If you want the sync to be performed periodically and automatically, you can create a script and then drop it into one of the cron directories, such as cron.daily. You can also setup a manual cron job in /etc/crontab. From now on, both sites will show identical information.

Check Also

Uk data center

Professional Data Centres In The UK

A professional data centre is a location in which various pieces of hardware are located …

Powered by Namesco
© Copyright InternetBlog.Org.Uk 2022, All Rights Reserved