6

I have a drupal site, and I am storing the codebase in a git repository. This seems to be working out well, but I'm also making changes to the database. I'm considering doing periodic dumps of the database and committing to git. I had a few questions about this.

  1. If I overwrite the file, will git think it is a brand new file or will it recognize that it is an altered version of the same file.

  2. Will this potentialy make my repo huge (the database is 16mb)

  3. Can I zip this file? or will this mess Git up ... the zipped version is only 3mb

  4. Any other suggestions?

1
  • 2
    You may want to check out the Drupal Answers Beta site. The more people who use it, the better chance it has of making it past beta: drupal.stackexchange.com
    – Matt V.
    Commented May 19, 2011 at 18:01

4 Answers 4

5

If you have enough space, a non-compressed dump in source control is pretty handy because you can compare using a diff program what rows were added/modified/deleted.

1
  • 1
    Just as an update - I tried it, adding the sql dump to git (overwriting the same file) then committing the new file. It did not seem to increase the size of the .git by much so I'm assuming it actually sees the changes ... I don't think however that this would work if the dump was g-zipped
    – user379468
    Commented May 19, 2011 at 23:06
1

Another solution is to use the features module which is supposed to capture drupal config in code. It stores this captured data as a feature module which you can put into version control.

0

For my database applications, I store scripts of DDL statements (like CREATE TABLE) in some sort of version control system. These scripts sometimes include static "seed" data as well. All the version control systems I use are good at recognizing differences in these files, and they are much smaller than the full database with data.

For the dynamically-generated data, I store backups (e.g. from mysqldump) in an appropriate location (depending on the importance of the data, that may include offsite backups).

4
  • "For the dynamically-generated data, I store backups (e.g. from mysqldump) in an appropriate location (depending on the importance of the data, that may include offsite backups)." ... does that mean that you are takeing multiple snapshots of the data and saving them all, or overwriting the same file and use Git to version them?
    – user379468
    Commented May 19, 2011 at 18:38
  • He meant: "is the dump always in the same file, or do you make a new file in the folder everytime ?".
    – wildpeaks
    Commented May 19, 2011 at 20:45
  • Just as an update - I tried it, adding the sql dump to git (overwriting the same file) then committing the new file. It did not seem to increase the size of the .git by much so I'm assuming it actually sees the changes ... I don't think however that this would work if the dump was g-zipped
    – user379468
    Commented May 19, 2011 at 23:05
  • @wild he edited his comment after I responded. I keep multiple dump files and age off ones that are "old enough" to not care about anymore (old enough varies by application). Commented May 20, 2011 at 18:34
0

1) It's all text, so GIT will just see it as it would any other file.

2) No, due to the above it should add 16mb to the repo (or less, due to GITs own compression), it won't add a new file every time, just the changes, so the repo will change by the size of the additions to the repository

3) No, or GIT won't be able to see the differences - GIT does it's own compression anyway

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