Script based on petdr's backup script.

Estimated hours taken: 2

backupdir:
	Script based on petdr's backup script.
	Will backup any CVS modules in the given directory.
	A compressed diff and a record of the version numbers of all
	files is created.

	The compressed diff can be applied using cvspatch.  A similar
	tool will need to be developed for using the version numbers.

	If the module is unchanged since the previous backup, no diff
	will be made (lightening the load on the CVS repository).

backuprevisions:
	Auxililary script, outputs the CVS/Entries file with the
	filename at the start.   This needs to be in your path when
	running backupdir.
This commit is contained in:
Tyson Dowd
1999-12-06 06:41:18 +00:00
parent 24e0f8bb78
commit 3aa0bc3940
2 changed files with 60 additions and 0 deletions

53
tools/backupdir Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/sh
#set -x
# Given a list of dirs, for each subdir in those dirs which is a CVS
# archive it produces a diff file that is compatible with cvspatch.
yesterday_date=`date --date "1 day ago" +"%Y-%m-%d"`
date=`date +"%Y-%m-%d"`
time="00:00:00"
cvsdate="$yesterday_date $time"
pwd=`pwd`
for dir in $@
do
for subdir in `ls $dir`
do
if [ -d $dir/$subdir/CVS ]
then
olddiff=`ls -t $pwd/$subdir-*.diff.gz | head -1`
oldrevisions=`ls -t $pwd/$subdir-*.revisions.gz | head -1`
diff=$pwd/$subdir-$date.diff.gz
revisions=$pwd/$subdir-$date.revisions.gz
# If there is no backup, make one
if [ z"$olddiff" == z ] ; then
echo "No backup for $dir/$subdir, making one"
(cd $dir/$subdir; cvs diff -u -N . 2> /dev/null |
gzip -9 > $diff)
(cd $dir/$subdir; find . -path '*CVS*' -name Entries \
-exec backuprevisions '{}' ';' | gzip -9 > $revisions)
# If there are changes in the directory since the backup,
# make a new backup.
elif [ x"`find $dir/$subdir/* -newer $olddiff`" != x ] ; then
echo "Changes in $dir/$subdir, making new backup"
(cd $dir/$subdir; cvs -f diff -u -N . 2> /dev/null |
gzip -9 > $diff)
(cd $dir/$subdir; find . -path '*CVS*' -name Entries \
-exec backuprevisions '{}' ';' | gzip -9 > $revisions)
else
touch $olddiff
touch $oldrevisions
fi
fi
done
done
# delete all the backups over 7 days old
find . -name "*.diff.gz" -mtime +7 -exec rm '{}' ';'
find . -name "*.revision.gz" -mtime +7 -exec rm '{}' ';'

7
tools/backuprevisions Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
echo $1
cat $1
echo
echo