Skip to main content

Synchronize 2 websites (1 direction A to B)

Comments

5 comments

  • cPanelMichael
    Hello, You can copy the content of /home/$username/public_html to another account via SSH with a command such as:
    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.
    0
  • psytanium
    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
    0
  • cPanelMichael
    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.
    0
  • psytanium
    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/
    0
  • cPanelMichael
    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.
    0

Please sign in to leave a comment.