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 never used git but now I need to use it as I'm trying to install Drupal. I installed MySQL, created user and gave permissions to user. Now, how can I put that database to git? I just want to take a backup of my database in the case of something goes wrong.

share|improve this question
    
drupal.org/node/856160 or drupal.org/project/dbscripts could help. Putting a dump of the MySQL database into a VCS isn't a good idea. –  VonC Feb 14 '11 at 15:01

3 Answers 3

up vote 1 down vote accepted

Hmm i think in this case git is not the right. When you want a backup you can use a master - slave replication.

With git your data is save when you make a git add and commit and push. In this case you have to do this process everytime.

share|improve this answer

Make a script?

pushd /path/to/repo
mysqldump --all-databases > db.sql
git add db.sql
git commit -m "Snapshot as of `date '+%Y-%m-%d'`"
git push
popd

I'm a way bigger fan of ZFS though. I completely agree with Stony's answer here, but if you really want to pump it to git, that's how you'd do it.

share|improve this answer

Use MySQL, ZFS and ZRM (Amanda) to do efficient snapshots... You can always add a export to tar option from a given point in time copy and remove the snapshot, for instance!.

Note that ZFS does run on Linux (Lawrence Livermore's modules), so if you're really looking for space and time efficient snapshotting, this is it!

Technically, one reason you need ZRM is so you can "freeze" DB operations for a second and have a consistent in-disk copy.

share|improve this answer
    
I'm a bit afraid that mysql might be in the middle of dumping a transaction if he uses ZFS. I'm a massive fan of ZFS either way. –  RandomInsano Jun 10 '12 at 7:45
    
Well, you can always go the path of running 'FLUSH TABLES WITH READ LOCK' and then use snapshots, then 'UNLOCK TABLES' to launch. –  Karthik Kumar Viswanathan Jun 10 '12 at 7:54
    
You sir, know far more about MySQL than I :D –  RandomInsano Jun 10 '12 at 7:57

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.