Recipe 18.15. Mirroring a CVS Repository

 < Day Day Up > 

18.15.1 Problem

You don't want your public, anonymous Pserver repository to be your main working repository; you would rather mirror it nightly, so that you can keep your working repository safely sheltered somewhere else, and keep access strictly controlled.

18.15.2 Solution

Put your Pserver and working CVS server on two separate boxes. Use rsync over SSH, with keychain managing authentication, automated by cron, to do a nightly upload to the Pserver. You need:

  • Two separate CVS repositories set up and working the anonymous public server and the private working server

  • OpenSSH set up and working for both repositories

  • rsync installed on the working repository

  • A mirroring script placed in a nightly cron job

This is the simplest rsync invocation, copying files from the working repository to the public repository. The user cvsadmin was created especially for this job:

#!/bin/bash source  /home/cvsadmin/.keychain/$HOSTNAME-sh rsync -av -e ssh  --cvs-exclude --delete --force /cvsroot  publiccvs.test.net:cvsroot/

Save the script as cvsmirror.sh or whatever you like, make it executable, and stick it in a cron job. This runs the script every morning at 2 a.m.:

# crontab -e 0 02 * * * /usr/local/bin/cvsmirror.sh

18.15.3 Discussion

The cvs-exclude option is a nice rsync feature that ignores the same files that CVS ignores.

This is a simple and perfectly serviceable script. One possible problem is running the mirror script while users are editing repository files. Any writes committed during the backup could be lost. CVS includes a locking mechanism, to lock files as read-only during a backup. This is rather complex to implement, but Chapter 6 of Essential CVS discusses the implementation in detail and provides locking and unlocking scripts.

You could probably get away with having the two repositories on the same box, but the risk is that anyone who compromises your Pserver could gain access to the whole system and get into your private, working CVS repository.

18.15.4 See Also

  • Chapter 16

  • Chapter 6 of Essential CVS

  • CVS home page (https://www.cvshome.org)

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net