From: Carl N Baldwin Date: Tue, 25 Oct 2005 22:14:01 +0000 (-0600) Subject: Some clean-up X-Git-Tag: release-0.4~66 X-Git-Url: http://git.pippins.net/embedvideo/.git/static/%7Bupdate_month%7D?a=commitdiff_plain;h=11b38584ce4c12e7a83c1cb206fa87141f74de5c;p=backups%2F.git Some clean-up --- diff --git a/scripts/Makefile.am b/scripts/Makefile.am index a4cb576..ba618aa 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,13 +1,11 @@ bin_SCRIPTS = \ drive.sh \ files-from-date.sh \ - find-cmd.sh \ list-dates.sh \ restore-script.sh \ - rsync-cmd.sh \ restore.sh -EXTRA_DIST = $(bin_SCRIPTS) +EXTRA_DIST = $(bin_SCRIPTS) restore-header.sh restore_scripts = \ files-from-date.sh \ diff --git a/scripts/drive.sh b/scripts/drive.sh index a75c20f..4ea1e54 100755 --- a/scripts/drive.sh +++ b/scripts/drive.sh @@ -15,6 +15,7 @@ backups="$tmpdir/backup-list.db" statusfile="$tmpdir/backup-status.txt" isomountdir="/backup/iso-mount" isoimage="/backup/iso-mount.iso" +restorescript="$scriptsdir/restore.sh" echo "Creating the iso image in $isoimage" touch $isoimage @@ -34,7 +35,12 @@ chmod 700 $tmpdir touch $currentfiles chmod 600 $currentfiles echo "Running find to get the status of files" -find-cmd.sh /home > $currentfiles +{ + for type in d f l; do + findformat="$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0" + find /home -type $type -printf "$findformat" + done +} > $currentfiles echo "Determining list of files to backup with lsbackups" { @@ -44,10 +50,11 @@ echo "Determining list of files to backup with lsbackups" } | lsbackups > $backups 2>$statusfile echo "Running rsync to pack the image" -cat $backups | rsync-cmd.sh $isomountdir +rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress" +cat $backups | rsync $rsyncopts / $isomountdir echo "Copying over database and status file" -cp $statusfile $backupdb $isomountdir +cp $statusfile $backupdb $restorescript $isomountdir # umount $isomountdir diff --git a/scripts/find-cmd.sh b/scripts/find-cmd.sh deleted file mode 100755 index 51a3749..0000000 --- a/scripts/find-cmd.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -[ $# == 1 ] || exit 1 - -{ - for type in d f l; do - find $1 -type $type -printf "$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0" - done -} diff --git a/scripts/restore-header.sh b/scripts/restore-header.sh index ae67b1c..a147c62 100755 --- a/scripts/restore-header.sh +++ b/scripts/restore-header.sh @@ -1,14 +1,12 @@ #!/bin/sh export rundir=/tmp/restore-$(date +%Y%m%d%H%M%S) if ! mkdir $rundir; then - echo 2> "Cannot create temp dir" + echo >&2 "Cannot create temp dir" exit 1 fi -echo $rundir unset CDPATH export mountdir=$(cd $(dirname $0) && pwd) -echo $mountdir SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0` diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh index 5ae9fe7..1bf8dcc 100755 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -1,9 +1,5 @@ #!/bin/sh -echo "Ran restore script with $@" - -exit 0 - export PATH=$rundir:/bin:/usr/bin if [ $# != 1 ]; then @@ -12,17 +8,27 @@ if [ $# != 1 ]; then exit 1 fi -# Get the device with the CD in it here device=$(mount | grep "on $mountdir " | awk '{print$1}') -cp $mountdir/backups.db $mountdir +cp $mountdir/backups.db $mountdir/backup-status.txt $rundir +dbfile=$rundir/backups.db for date in $(cat $dbfile | list-dates.sh); do - eject $device - echo >&2 "Please insert backup disk: $date" - echo >&2 "Then press any key" - read bogus - # Mount the media - # rsync-cmd.sh won't work here in its current encarnation - cat $dbfile | files-from-date.sh | rsync-cmd.sh $1 + success=false + while ! $success; do + eject $device + echo >&2 "Please insert backup disk: $date" + read bogus + + # Mount the media + mount -t ext2 $device $mountdir + if [ "" != "$(grep -l $date $mountdir/backup-status.txt)" ]; then + success=true + else + echo >&2 "This doesn't seem to be the right disk." + fi + done + + rsyncopts="-l -p -t -g -o -0 --files-from=- --stats --progress " + cat $dbfile | files-from-date.sh | rsync $rsyncopts $1 $2 done diff --git a/scripts/rsync-cmd.sh b/scripts/rsync-cmd.sh deleted file mode 100755 index b1ea6c9..0000000 --- a/scripts/rsync-cmd.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# This file just has some ideas about how to do the rsync command with the list -# of file produced by lsbackups - -[ $# == 1 ] || exit 1 -[ -d $1 ] || exit 1 - -# -H ? -W ? -rsync_opts='-l -p -t -g -o -0 --files-from=-' - -other_opts='--stats --progress' - -# Should also include directories in there -rsync $rsync_opts $other_opts / $1