Create the self-extracting archive restore.sh
authorCarl N Baldwin <cnb@hpsvcnb.fc.hp.com>
Tue, 25 Oct 2005 21:55:44 +0000 (15:55 -0600)
committerCarl N Baldwin <cnb@hpsvcnb.fc.hp.com>
Tue, 25 Oct 2005 21:55:44 +0000 (15:55 -0600)
scripts/Makefile.am
scripts/restore-header.sh [new file with mode: 0755]
scripts/restore-script.sh [changed mode: 0644->0755]
scripts/rsync-cmd.sh

index 2afda8723b96e31e92fd516013f87dae88a278f1..a4cb5768639f95344abb78d9b721a95b75adc45a 100644 (file)
@@ -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 (executable)
index 0000000..ae67b1c
--- /dev/null
@@ -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__
old mode 100644 (file)
new mode 100755 (executable)
index 402bb84..5ae9fe7
@@ -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 <target-directory>"
-  echo >&2 "Example: $0 /"
+  echo >&2 "Usage: $0 <source-directory> <target-directory>"
+  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
index aa7e9f78562e3794f29235416aa23ff2473617c6..b1ea6c9d1e159abdaeee8fa010d7610b1b30fa8a 100755 (executable)
@@ -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'