i'm going to change my dedicated server.

I'm running under

  • OS: Debian5.
  • Database : MySQL
  • iRed Mail server
  • 6 Websites (3000 files for each) on it

The new sever is to be setup the same, only hardware changes (Debian5)

How would you proceed?

I never did a server backup before, I heard about "scp" command.


  • 1
  • thanks i'll read this, but i don't know if it's for me i'm not going to backup the entire system and i can't access physically the server to change the harddrive. – Tristan Sep 3 '10 at 20:22
  • Can you elaborate on what you mean by not going to backup the entire system, are you looking to selectively migrate some data? I was under the impression that you wanted to transfer the entire working install from the old hardware to the new hardware. – Zoredache Sep 3 '10 at 20:27
  • yeah, it seems a little to heavy, when i'll order the new server, it'll have debian5 already installed on it. So i'm only going to export the Mysql database + user, website, php cfg, iredmail server... that's why i asked how to do it correctly – Tristan Sep 3 '10 at 20:35

Set up MySQL replication to have the two servers in sync.

For the flat files, do an initial

tar zcf - mydirs/ | ssh user@remotehost 'tar zxpf - -C mydest/dir'

and then use rsync to copy over changes in an efficient manner on a regular schedule (at least once a day, but can be more often). It's also certainly possible to use rsync for the initial copy, but I find tar or cpio quicker.

Drop the DNS TTLs to ~15 minutes.

At the time of the switch over, put up a maintenance page and then:

  • stop mail services
  • stop MySQL replication
  • point DNS records to the new server (which also has the maintenance text up)
  • do a final rsync of the files
  • restart services
  • take the maintenance page down
  • wait a few days and then raise your DNS TTLs to where they were once things are good

This way you always have two sets of files, and you can test things on the new server while still having the old one untouched (besides a MySQL tweak).

If anything strange goes south with the new server you can always switch back to the old one quite quickly (~15 minutes because of the TTLs).


Generally Linux installs are very easy to migrate. You can use a tool like DD to take an image of the old drive or partitions, and then restore them on the new box.

You can manually partition the new box and use something like rsync to transfer files.

You can do a base install on the new system and use rsync to transfer files.

The one important thing to remember in your situation is to stop the mysql, server before doing backup. Like most databases, copying the mysql data files while mysql is using them is likely to result in a corrupt database.

  • ok thanks didn't know about stopping mysql, what did i need to copy ? the entire mysql folder ? or only exporting all the databases ? – Tristan Sep 3 '10 at 20:32
  • Export the databases, use mysqldump. – coredump Sep 4 '10 at 0:00
  • Filesystem level backups (dd, dump etc) are inherently dangerous - they backup more than just files. – symcbean Sep 6 '10 at 11:21

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.