Create the self-extracting archive restore.sh
[backups/.git] / scripts / restore-header.sh
1 #!/bin/sh
2 export rundir=/tmp/restore-$(date +%Y%m%d%H%M%S)
3 if ! mkdir $rundir; then
4   echo 2> "Cannot create temp dir"
5   exit 1
6 fi
7 echo $rundir
8
9 unset CDPATH
10 export mountdir=$(cd $(dirname $0) && pwd)
11 echo $mountdir
12
13 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
14
15 # take the archive portion of this file and pipe it to tar
16 tail +$SKIP $0 | tar xzf - -C $rundir
17
18 exec $rundir/restore-script.sh ${1+"$@"}
19
20 __ARCHIVE_FOLLOWS__