Let's say I have two web servers (in a datacenter), A and B. I don't have physical access to any of the servers, only root ssh access.

A is an old server with old hardware, but it's configured the way I want it (security, settings, etc..), while B is a new server with newer hardware (totally different from A), and it has a fresh install of CentOS (for example).

What's the best way to clone server A to server B, so all my files,settings,applications are moved from A to B?

  • 2
    Don't. Chances are high that the newer versions of the programs don't work with the old config. Maybe not all, but some. Configure the new server manually. – Gerald Schneider Aug 7 '18 at 9:24
  • 2
    "Cloning" implies a bit-for-bit copy of all data and settings, which is usually at odds with 'migrating" both your data and configuration settings to a new major OS version and newer versions of your application layer. – HBruijn Aug 7 '18 at 9:26

If the newer server runs the same OS version, you could run a simple script from the newer server that copies most of the files:


# Source


printf '%s\n' $EXCLUDE > exclude.txt
rsync -avz --exclude-from=exclude.txt -e "ssh -p $SSHPORT" $SSHSERVER:/ /

I used this script in the past to duplicate Debian servers, and it worked fine but some manual (re)configuration, like apt-get install -f was sometimes required. Therefore, use with caution, perferrably in a test environment first.


Migrate, do not clone. Different versions, different hardware, evolving best practices will require slightly different configuration.

Spend some effort to create documentation and automation to configure a fresh OS install from scratch. This might be a well-commented script or playbook. Use this to deploy.

If near-identical hardware or VM, that could be a clone. Copy the entire OS disk and re-IP it. You inherit all the quirks of the old install, but it is the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.