need help getting site into a SVN repository

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
gallamine's picture

Hey all,
I've finally gotten to the point of moving my site into the "real world" and off of my desktop running XAMPP. I'm trying to do things proper and I've set up a SVN server at Beanstalk (www.beanstalkapp.com/). So, at this point I'm trying to figure out how to best manage the site and the repository. I'm a SVN newbie, so I'm struggling with how I should go about adding my site files to the repository. I'm using Tortoise SVN for windows. So, should I make a new repository and add the whole Drupal installing into that folder? Or, should I create a repository inside the drupal folder and add the /sites/.. folder into the repository?
I ultimately want to be to be able to have the main live site get committed to the repository every day, then get copied to a test site. I'm just not sure how to best get things initially set up. I wasn't sure where to ask this question, so I'll start here first.
Thanks.

Comments

SVN Setup

JuliaKM's picture

I haven't used Beanstalk or TortiseSVN before. Here's how I've set up the folders in my repository.

sql/ (contains my most recent database dumps)
docs/ (help documentation, project planning notes)
www/
www/branches/
www/branches/branch-1.0/ (the current code branch, a release is a snapshot of the branch)
www/trunk/ (the latest development version of the code)
www/releases/ (the live version of the code)

When I commit to www/trunk/, then my site at dev.mysite.org updates via a post-commit hook. When I commit to branch-1.0, the site updates at stage.mysite.org. When it comes time to add a new release, I usually do a svn export. I think that there may be better options though.

As for how to get the files in, if I were you, I'd probably create a folder structure and then add in the files on your local computer.

One thing to keep in mind is that is can be tricky to account for updates to Drupal core code with SVN. I tend to just do svn delete for the core files and then copy in and add the new ones back into my repository. This isn't ideal and I would be curious to hear what others are doing. I know that svn externals is an option and I'd like to hear from anyone that got it working.

For updating modules and themes, I've found that the drush svn module works really well.

SVN setup

zaloni's picture

There are many ways of implementing SVN workflows for your Drupal installation. I prefer to keep the whole Drupal install in SVN and not just the sites folder. When you say you want to have the main live site committed to the repository every day, I am assuming that you are expecting a high rate of change in the files and other assets of the site and not necessarily the source code. You may also want to tag the checkin and pair it with a DB backup with the same name/tag so that your source and database are in sync when you need to restore them in test or for disaster recovery reasons.

HTH,
-Ben
Zaloni

Julia and Ben, Thanks for

gallamine's picture

Julia and Ben,
Thanks for the input. I'll keep playing around with things.

@Julia, do you keep the whole Drupal install in your SVN repository? Is there a definite advantage to that? I just figured I didn't need to version Drupal on my server when it gets done on Drupal.org. But, I guess I can see some advantages.

@Ben, yes, I planning on users adding data and files to the site. So, I'd like to make sure that the database and new files get committed to the repository each night. I guess I'll need to set up a cron job to do that. I haven't learned anything about tags yet, but I guess I'll get to that at some point. Is the best method of backing up the database just to do a mysqldump to a file?

SVN...

JuliaKM's picture

Do you keep the whole Drupal install in your SVN repository? Is there a definite advantage to that?

I keep the whole Drupal install in my repository but sometimes it ends up being a pain. For example, I just upgraded from 6.9 to 6.10 and I had to clean up a bunch of svn problems before getting it to work correctly. I think that a better strategy is probably to put the drupal-install/modules folder and other core code in a separate directory and symlink to your version. Then, when a new version is release, you could just update your symlink. I suppose that svn externals probably works the same way.

What I would really love is to be able to update Drupal core via the command line using Drush. That's what I do for my contrib modules and it works really well. @Ben: any ideas on how to do this?

I don't think Drush will be

gallamine's picture

I don't think Drush will be able to update the core, as it's a module itself.
But, this guy uses a combination of SVN and CVS to maintain his repository and keep drupal updated: http://nicksergeant.com/blog/drupal/painless-drupal-revision-control-cvs...

Basically he keeps a version of Drupal in his SVN repository, and when Drupal rolls out an update, he does a "cvs update -r DRUPAL-5-7 -dP" to update the Drupal core files, then commits that to the SVN repo.

@JuliaKM what do you do

gallamine's picture

@JuliaKM what do you do about the configuration file? Do you have a separate file for each server that isn't in your repository? I'm assuming you'll need to do this since each server has a different database/password. Maybe there some fancy SVN magic you can do to have separate files for each location where checkout lives?

Configuration File

JuliaKM's picture

I also have a production, staging, and development database that are in my settings.php file that are switched depending on the HTTP_HOST. My code basically does this:

if ($_SERVER['HTTP_HOST'] == 'dev.example.org') {
    $db_url = 'mysqli://test:test@mysql.example.org/dev_example';
}

elseif ($_SERVER['HTTP_HOST'] == 'stage.example.org') {
    $db_url = 'mysqli://test:test@mysql.example.org/stage_example';
}

elseif ($_SERVER['HTTP_HOST'] == 'live.example.org') {
    $db_url = 'mysqli://test:test@mysql.example.org/live_example';
}

I do the same thing for the $cookie_domain variable. I'm not sure if you have to though.

In regards to the whole

gallamine's picture

In regards to the whole deployment issue, this looks like it will be a neat module: http://drupal.org/project/deploy
I haven't tried it out yet. Anyone else?

triDUG

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week