From 5c8c182b0f51eaa5fca5f917ed5cda5f12fb7366 Mon Sep 17 00:00:00 2001 From: Carl N Baldwin Date: Tue, 25 Oct 2005 15:55:44 -0600 Subject: [PATCH] Create the self-extracting archive restore.sh --- scripts/Makefile.am | 17 ++++++++++++++++- scripts/restore-header.sh | 20 ++++++++++++++++++++ scripts/restore-script.sh | 18 +++++++++++------- scripts/rsync-cmd.sh | 2 +- 4 files changed, 48 insertions(+), 9 deletions(-) create mode 100755 scripts/restore-header.sh mode change 100644 => 100755 scripts/restore-script.sh diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 2afda87..a4cb576 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -4,6 +4,21 @@ bin_SCRIPTS = \ find-cmd.sh \ list-dates.sh \ restore-script.sh \ - rsync-cmd.sh + rsync-cmd.sh \ + restore.sh EXTRA_DIST = $(bin_SCRIPTS) + +restore_scripts = \ + files-from-date.sh \ + list-dates.sh \ + restore-script.sh + +restore_tar = restore.tgz + +restore.sh : restore-header.sh $(restore_tar) + { cat $<; cat $(restore_tar); } > $@ + chmod +x $@ + +$(restore_tar) : $(restore_scripts) + tar cf - $^ | gzip > $@ diff --git a/scripts/restore-header.sh b/scripts/restore-header.sh new file mode 100755 index 0000000..ae67b1c --- /dev/null +++ b/scripts/restore-header.sh @@ -0,0 +1,20 @@ +#!/bin/sh +export rundir=/tmp/restore-$(date +%Y%m%d%H%M%S) +if ! mkdir $rundir; then + 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` + +# take the archive portion of this file and pipe it to tar +tail +$SKIP $0 | tar xzf - -C $rundir + +exec $rundir/restore-script.sh ${1+"$@"} + +__ARCHIVE_FOLLOWS__ diff --git a/scripts/restore-script.sh b/scripts/restore-script.sh old mode 100644 new mode 100755 index 402bb84..5ae9fe7 --- a/scripts/restore-script.sh +++ b/scripts/restore-script.sh @@ -1,17 +1,21 @@ #!/bin/sh +echo "Ran restore script with $@" + +exit 0 + +export PATH=$rundir:/bin:/usr/bin + if [ $# != 1 ]; then - echo >&2 "Usage: $0 " - echo >&2 "Example: $0 /" + echo >&2 "Usage: $0 " + echo >&2 "Example: $0 / /" exit 1 fi -tmpdir=/tmp/restore-$(date +%Y%m%d%H%M%S) - -export PATH=$tmpdir:/bin:/usr/bin - # Get the device with the CD in it here -device=/dev/hdc +device=$(mount | grep "on $mountdir " | awk '{print$1}') + +cp $mountdir/backups.db $mountdir for date in $(cat $dbfile | list-dates.sh); do eject $device diff --git a/scripts/rsync-cmd.sh b/scripts/rsync-cmd.sh index aa7e9f7..b1ea6c9 100755 --- a/scripts/rsync-cmd.sh +++ b/scripts/rsync-cmd.sh @@ -7,7 +7,7 @@ [ -d $1 ] || exit 1 # -H ? -W ? -rsync_opts='-W -H -l -p -t -g -o -0 --files-from=-' +rsync_opts='-l -p -t -g -o -0 --files-from=-' other_opts='--stats --progress' -- 2.34.1