I would like to ask if its possible. I have recently ordered a new dedicated server for my website. The server is slightly different from the current one. Both are quad core xeons, the differences are the current one is 500GB Hard disk - new one is 160GB hard disk (but I havent consumed 50gb). Next is the memory, 24GB on the old one and the new one is 12GB RAM. Both are Centos 5.6 with up to date patches using yum update.

I was wondering if its possible to backup and restore everything including nginx, php53u-fpm, mysql, including all the configurations and databases + website files. Is this possible to backup and restore without any problems?

I would want to back everything up in one go, (not one by one then importing it one by one).

  • 2
    Are you sure you want to ask "is it possible" and not "how can I do it"? Because I can answer the first, not the second. Yes, it is possible. ;) – TessellatingHeckler Aug 22 '11 at 16:56
  • Well, I wanna know both – Ansell Aug 22 '11 at 17:12
  • Looking at the comments, I guess I was wrong. Linux can update the kernel without a reboot, but you can't clone one set of system files over another, as if doing a backup and restore? Maybe you only can't while it's running? – TessellatingHeckler Aug 22 '11 at 19:27

Quick answer, no!

Moving stuff like nginx, php etc is not a good idea. You'll end up with a corrup RPM database (presuming you have installed these applications via rpm) and you could accidently over write existing config files (such as passwd/fstab etc). Trying to find a shortcut to do this will just lead to wasting more time trying to puzzle stuff together.

The best way to migrate is to go through you're old server and see what files you actually need to move. Apps should be installed in the same way you did on the old machine, yum install or whatever. Try to keep to the same major patch levels if possible to avoid having both new versions and a new server to troubleshoot. For the files to copy there shouldn't be that tricky to find what you need, in nginx/php there should only be the configuration files, additional php/pear modules and obviously your web application tree to copy. To migrate the MySQL database use mysqldump and restore the dump on the remote machine, if you have customized my.cnf make sure you copy that file too.

I'm sure I've forgot something in this list but you get the concept, just be methodical and go through what you need to do. Do as much as you can in advance and when doing the switchover to the new machine just copy the fresh database over and whatever files need to be refreshed, configuration files should already be in place.

  • Why can't you copy everything over, and then not have a corrupt RPM database? Imagine you backed up to tape, you would need to make a new working Linux install to read the tape to do a restore, and then need to restore over the top of your running system reading from the tape to get back to how it was before, yes? Why can't you do that substituting something else for the tape, like an SSH session with a TAR archive at the other side? – TessellatingHeckler Aug 22 '11 at 19:29
  • If you do the whole process booted from a temporary media with your destination system chrooted, like PXE or a DVD you could restore a whole system from a tar, dump or cpio archive and update whatever you need to update if the system is different (the initrd if drivers required are different, fstab etc etc). If you restore to an already installed and running system you'd most likely get problems. – HampusLi Aug 23 '11 at 6:33
  • There is no reason to corrupt the rpm database unless you tamper it. On the other side, overwriting existing config files is exactly what he wants. – Ochoto Aug 23 '11 at 20:01

So if you have a remote machine, get a server that you will use to prepare the harddrive Mount your new harddrive to /mnt a linux machine

Then on your current machine do :

 find / -xdev | ssh urname@urLinuxMachineToBackup  "cpio -pm /mnt"

This should copy everything from your old hard drive to your new harddrive with all the file permissions (cloning your machine).

With both machines already running there isn't a way to just clone them. You would need another VM at least and access to the host.

  • Hi, The problem is this 2 servers are from different ccountries and everything should be done via SSH. – Ansell Aug 22 '11 at 17:20
  • Edited the answer, however forget it if you don't have physical access, if you have 2 machines running and only remote access, you will not have a way to clone them. – Lucas Kauffman Aug 22 '11 at 17:32

Learn to use "tar". It's made to create backups/archives.

(Hint: create a "backup" directory on your old host, copy stuff you want to keep (configuration files, data, databases etc) into that directory, make an archive (with tar) of that directory, ftp/scp it over to your new host, unpack it, move files around, recieve major win etc..

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.