Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a quick question. I would like to create a backup of my entire centos VPS, including mysql. Would this work?

tar -zcvpf /backup/testbackup.tar.gz --directory /

Can I restore a tar backup by simply untaring it, since mysql stores databases in /var/lib/mysql or would I need to additionally create mysqldumps for every database

share|improve this question
Why not use one of the many VPS providers to provide snapshot backups? – ceejayoz Nov 26 '12 at 21:03
up vote 0 down vote accepted

You could... But I wouldn't.

When you use mysqldump, 2 important things happen. Firstly, the databases are locked whilst the dump happens, so you don't get inconsistent data in your backups, which might require table repair after restoration.

Secondly, you get a .sql file which is platform independent. You can targz up a /var/lib/mysql directory, but you'd only ever be able to restore it onto a platform with the identical specification of the one you dumped it from. Good luck restoring onto a SPARC server, or even X86-64 might subtly corrupt the data. With a SQL file, you just restore it, and it's good to go.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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