How to backup the CVS repository


More scribblings on CVS...

As always, your own your own if the script mess your files up, I just provide the info you are responsible for what you do with it

Any feedback is highly appreciated, you can contact me at this email adress:

1 Backup of CVS

Below is a script I use to make a backup of the part of the CVS that I use.
The CVS server we had at my company was not backed up regularly(!), so this was my paranoia to make sure that my stuff would not get lost.

Note that you must use pax if you need to extract the tars.
The files in the tarfile is stored with absolute paths, so you need to strip the leading / if you want to extract the files (otherwise it will try to extract the files to /cvs... )
do this to extract the files to a directory cvsbkp/ pax -rv -f thetarfile.tar -s "/\/cvs\/data\//cvsbkp\//g"

2 Source code

 #!/bin/ksh
 #
 # More scripts and tips can be found at
 # http://www.edlin.org/
 #
 # Script to generate BACKUPS of a part of the CVS repository (dilbert is the cvs server)
 #
 
 _ftp_file()
 {
   stty -echo
   read -r PASSWORD?"Enter password for user $2 : "
   stty echo
   print
 
   #$1 = server
   #$2 = userid
   #$3 = source
   #$4 = targetdirectory
 
   #extract filename
   filename="`expr "//$3" : '.*/\([^/]*\)'`"
 
   ftp -in $1 <<EOF
     user $2 $PASSWORD
     bin
     get $3 $4${filename}
     quit
 EOF
 }
 
 echo "Script to generate BACKUPS of a part of the CVS repository"
 echo "----------------------------------------------------------"
 echo "This script will make a tarfile of the files at dilbert:/cvs/data/theFiles"
 echo "it will save the tar-file in the directory \"bkps\", so make sure that directory exists"
 echo "NOTE: The files are stored with ABSOLUTE paths in the tarfile, so you need"
 echo "to use pax to extract the files somewhere else"
 
 filename="cvs_theFilesbackup_`date +"%Y_%m_%d_%H%M"`.tar"
 
 echo "Logging in to server to create the tarfile..."
 #Note: you might need to login as soem other user to be able to read the data in /cvs/data/
 #it depends on how your cvs is set up
 rexec dilbert -l ${USER} "tar cf /tmp/${filename} /cvs/data/theFiles"
 
 echo "FTP the tar file over to this server..."
 _ftp_file "dilbert" "${USER}" "/tmp/${filename}" "/home/${USER}/bkps/"
 
 echo "Logging in to server to delete the tarfile..."
 rexec dilbert -l ${USER} "rm /tmp/${filename}"
 
 gzip /home/${USER}/bkps/${filename}
 



How to contact me
Welcome to
www.Edlin.org
Computing, CS links
Design Patterns
Distribution process
CVS, Backupscript for CVS
Perl tips, Perl links
DHTML/JavaScript/etc
Searchengines
My Bookmarklets
Nostalgia: Atari ST
HP Bluestone
Other stuff
Science Ficton/Fantasy
My Book Reviews
Author: Tom Holt
Bestselling books, May 2005
John Cleese
and much more ....
Contact