Synchronize 2 websites (1 direction A to B)

psytanium

Well-Known Member
Jun 6, 2014
282
15
68
Lebanon
cPanel Access Level
Root Administrator
Hi,

website1.com and website2.com are located on the same vps server. I'm trying to make website2 look the same as website 1 with only 1 difference, another logo.

is there a way to do it from cpanel tools or WHM ?

thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
Hello,

You can copy the content of /home/$username/public_html to another account via SSH with a command such as:

Code:
cp -a /home/$username/public_html/* /home/$username2/public_html/
Ensure you update the ownership of the files in the new account to the new account username using the "chown" command.

The other option is to manually download the files via FTP from one account, then upload them to the new account via FTP.

Thank you.
 

psytanium

Well-Known Member
Jun 6, 2014
282
15
68
Lebanon
cPanel Access Level
Root Administrator
Can I use this command line in Cron Job ?
Can I add exceptions ? I need to copy all the content of public_html without except public_html/images/logo.png
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
You could setup a cron job with a custom "rsync" command if you want to ensure files are copied to other locations on the system. Ensure you use the correct arguments for permission and ownership values so that files are owned by the correct user after copied to the new account. Here's a StackOverflow discussion on "rsync" that should help you get started:

How do I copy a folder keeping owners and permissions intact?

Thank you.
 
  • Like
Reactions: psytanium

psytanium

Well-Known Member
Jun 6, 2014
282
15
68
Lebanon
cPanel Access Level
Root Administrator
I'm reading about rsync command and how to use it in cronjob.
Trying to sync public_html from user1 to user 2 on the same server, this is correct ?

rsync -r /home/user1/public_html/ /home/user2/public_html/
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
I'm reading about rsync command and how to use it in cronjob.
Trying to sync public_html from user1 to user 2 on the same server, this is correct ?

rsync -r /home/user1/public_html/ /home/user2/public_html/
You may find this URL helpful:

rsync between two local directories

You'd need to ensure the ownership of the files matches the second user after the files are copied as well. Here's a manual on rsync:

rsync(1) - Linux man page

Thank you.