views:

57

answers:

1

I want to use git for the deployment of a django project as I have done before, but this time it would also be necessary to have production files (like uploaded files, sql db etc) somewhere in the repository, so that you can locally work easily with the same data as on the server; my idea would be to have three branches:

  • master (on which the "normal" development is done/commited)
  • production (that has additionally the production files (file uploads etc...)
  • deployment (production with settings etc used for running on server)

The problem for me is: How to merge the changes done in master into the production branch, without changing/destroying any production data?

Is there a way to do merging selectively (eg not touch the files in media/uploads), or do some kind of "branch-selective tracking " or any other possibility to handle this?

On the other hand I also need to be able to pull the complete data coming from production use easily from the server to do some debugging for example... (I'm leaving database scheme changes out of this considerations right now because they could be done manually or in a seperate way)

+1  A: 

i'm a bit confused by your server names, i'm more used to: production, staging, development.

you should probably dump the database as sql code, or whatever way you want to output the data in, then transfer it to your master (development?) server. you could do that by uploading it to a git repository on production and pulling it on development. Fabric would make that very easy.

but putting the data in a git repository probably isn't such a great idea, i haven't tried merging database dumps, so I'm not too sure. how much data are you talking about? git is fast, but merging and committing large database dumps might be a painful process.

we tend to have small test-databases on our local machines (that can get wiped) and are running one staging server next to the production server, with separate DBs.

when the underlying django models change we use South on our staging and production server to migrate to the new database.

uploaded files you should probably tar with Fabric and then download to your machine for analysis, but again a lot of that work can be done on the staging server, without having to transfer all the content to your local machine.

if you still want to add static stuff to your git repository, simply add the static files in a subdirectory. then you can either set your file server to serve straight from that subdirectory, or if that feels too insecure, git pull to some other location and then copy the files to /var/www-static/ with Fabric.

rdrey
Thanks for you answer, I'll have a look at Fabric. Already using South, but as I mentioned, the database is not the only problem...
lazerscience