Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
3  
Why not use one of the many VPS providers to provide snapshot backups? –  ceejayoz Nov 26 '12 at 21:03

1 Answer 1

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

 
discard

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.