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:
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"
#!/bin/ksh
#
# More scripts and tips can be found at
# http://www.edlin.org/sitemap.html
#
# 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}