From 3aa0bc39407bd848eda56ffe95639e6d54e458e3 Mon Sep 17 00:00:00 2001 From: Tyson Dowd Date: Mon, 6 Dec 1999 06:41:18 +0000 Subject: [PATCH] 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. --- tools/backupdir | 53 +++++++++++++++++++++++++++++++++++++++++++ tools/backuprevisions | 7 ++++++ 2 files changed, 60 insertions(+) create mode 100755 tools/backupdir create mode 100755 tools/backuprevisions diff --git a/tools/backupdir b/tools/backupdir new file mode 100755 index 000000000..ad77a1805 --- /dev/null +++ b/tools/backupdir @@ -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 '{}' ';' + diff --git a/tools/backuprevisions b/tools/backuprevisions new file mode 100755 index 000000000..189afdb78 --- /dev/null +++ b/tools/backuprevisions @@ -0,0 +1,7 @@ +#!/bin/sh + +echo $1 +cat $1 +echo +echo +