rsync Drupal CVS repositories

Last modified: November 25, 2008 - 01:13

If you travel a lot, have a long daily commute, or otherwise have big chunks of time spent offline, there can be a lot of advantages to having a local copy of the core and/or contributions CVS repositories available.

Fortunately, drupal.org provides the following rsync mirrors of cvs.drupal.org:

$ rsync cvs.drupal.org::
cvsbackup     
bzr           
cvsmirror-core
cvsmirror-contrib

These mirrors allow you to easily make a local copy of the repository that has all the version information and/or import it all into an alternate RCS, such as Subversion. You can then checkout/diff/etc. against the local repository when you are offline.

Please note that the following paths are for Mac OS X; you may need to use different paths for Unix/Linux, or create a separate user account for your repository with common group read/write permissions.

Setting up a local core repository

  1. Begin by creating a local CVS repository to hold the files.

    $ cd /Users/Shared
    $ mkdir /Users/Shared/code
    $ cvs -d/Users/Shared/code init
    $ cvs -d/Users/Shared/code co CVSROOT
    $ cd CVSROOT

  2. Edit the /Users/Shared/CVSROOT/modules file:
    $ nano CVSROOT/modules
  3. Add the following line at the bottom of the file:
    drupal drupal
  4. Exit the editor and commit your changes:
    $ cvs -d/Users/Shared/code ci -m"add Drupal core to local repository."
  5. Execute the following command to get rsync to grab the files from cvs.drupal.org:
    $ rsync -avz --delete cvs.drupal.org::cvsmirror-core/drupal /Users/Shared/code

You can then checkout core on any available branch or tag locally:

$ cd /Applications/MAMP/htdocs
$ cvs -d/Users/Shared/code co -d drupal-7 drupal
$ cvs -d/Users/Shared/code co -d drupal-6 -rDRUPAL-6 drupal

Setting up a local contributions repository

  1. If you haven't already, complete step 1 above to create your local CVS repository.
  2. Edit the /Users/Shared/CVSROOT/modules file:
    $ nano CVSROOT/modules
  3. Add the following line at the bottom of the file:
    contributions contributions
  4. Exit the editor and commit your changes:
    $ cvs -d/Users/Shared/code ci -m"Add Drupal contributions to local repository."
  5. Execute the following command to get rsync to grab the files from cvs.drupal.org (Note: this will take a long time):
    $ rsync -avz --delete cvs.drupal.org::cvsmirror-contrib/contributions /Users/Shared/code

You can then checkout core on any available branch or tag locally:

$ cd /Applications/MAMP/htdocs/drupal-6
$ cvs -d/Users/Shared/code co -d views -r DRUPAL-6--1 contributions/modules/views

Keeping things in sync

Once you have this setup, its nice to ensure your copy of Drupal CVS stays up to date. You can do this by executing the rsync command on a cron job. For example:

  1. Edit your crontab file:
    $ crontab -e
  2. Add the following lines to crontab to run the rsync command once per hour:
    21 * * * *      rsync -avz --delete cvs.drupal.org::cvsmirror-core/drupal /Users/Shared/code  > /dev/null 2>&1
    21 * * * *      rsync -avz --delete cvs.drupal.org::cvsmirror-contrib/contributions /Users/Shared/code  > /dev/null 2>&1

When you use cvs update, you will get updates based on the changes that rsync pulls down from the mirror (so they may be delayed an hour compared to updating directly against the cvs server).

 
 

Drupal is a registered trademark of Dries Buytaert.