1

I'm developing a php-application that collects certain data from a bunch of servers.

I backup this data regularly. Quite often I also want to restore the database to a certain state while developing. For instance there might be a bug related to a certain backed up state. I've got this set up with bat-files which dump the database to a new file, and let me restore to a certain dump-file. However the data now also include filesystem-files which are pointed to by database-fields. How would one in a convenient way backup both the database and the related files in a synchronized manner, and so that they are isolated from the rest of the project-files? One way that came to mind while writing this is to put all files that relate to the database in a common folder and then have a nested git repository ("Submodules") along with git-hooks that dump database when committing and restores during checkout. But I've got no experience with submodules this and wonder if this even would be a sensible way of doing it?

Clox
  • 1,923
  • 5
  • 28
  • 43

1 Answers1

1

I would avoid storing a large binary file in a git repo.

I would rather keep the database saved file separate, but with a special name: a name incluiding the SHA1 of the repo.
And I would backup the repo at the same time, as a bundle (meaning as just one file)

That way, you keep a couple of files (ie 2) each time you save: one for the database, one for the repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! Do you think you could elaborate a bit of how you would do that in practice? I'm not familiar with bundles but I just looked it up and if I understand correctly it is one file that contains the entire repository, either a single commit or a range of them. So are we talking a single commit or multi? Would you save the repo as a bundle of the new commit, along with the database-dump that relates to it and then put them on some kind of drive or such? All the database-related files should then be inside the repo? I think I'm misunderstanding something because it doesn't make sense to me. – Clox Sep 28 '14 at 09:40
  • @Clox yes, a bundle can have the full repo history, or it can be an incremental bundle (I would recommend, if the size isn't too important, to make full bundles only). "All the database-related files should then be inside the repo": if those are text files, yes. – VonC Sep 28 '14 at 09:55
  • @Clox I use bundmles for backup all the time: see http://stackoverflow.com/a/23712022/6309, and the referenced script (https://github.com/VonC/compileEverything/blob/1b01af253eb938efe8f04eb44f9e8af0d9633baa/sbin/save_bundles#L111) – VonC Sep 28 '14 at 09:57
  • @Clox I am talking, for the database, about making an archive (which again contains a large binary file, unfit to be stored in a git repo because of the poor binary diff capability). If that archive is named after the SHA1 of the repo (like a git describe does: http://lostechies.com/joshuaflanagan/2010/04/08/adding-git-commit-information-to-your-assemblies/), then the archive can easily be linked to a specific version of that repo, even though it is stored outside of any git repo. – VonC Sep 28 '14 at 10:00
  • I don't quite follow.. Sorry, guess I'm slow. None of the "database-related files" as I refer to them as are text-files which is the reason they're not stored in the database in the first place. Everyone seems to recommend not saving such files in the database so my database merely holds their filenames. By he way, correct me if I'm wrong but aren't mysql dump files flat text files and not binary files? – Clox Sep 28 '14 at 20:30