]> git.sesse.net Git - backup.sh/commitdiff
Always assume /root exists for root, instead of trying to go through hoops to expand ~.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 4 Oct 2014 22:41:53 +0000 (00:41 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 4 Oct 2014 22:41:53 +0000 (00:41 +0200)
backup.sh

index 5c240aa87ed6c74f1c48f27d0b9491b78901cd2e..075f89ad02502223901be9530af16f26403727b2 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -96,9 +96,6 @@ backup()
                lastcmd="--listed-incremental=$incrementalsnar"
        fi
 
-       # expand the exclude-path for use with tar
-       exf=`ssh root@$computer "ls ~/.backup/exclude"`
-
        # We try to run tar on the remote computer
        #    c create archive
        #    C change to directory first
@@ -111,7 +108,7 @@ backup()
        #    file and build a file list, respectivly.  
        TARFILE=$DATE.tmp
        TARCMD="ssh root@$computer \"nice -n 19 ionice -c3 tar --one-file-system --use-compress-program $compressor -cf - -C $filesystem . $lastcmd \
-               --exclude-from=$exf\" | pee \"cat > $TARFILE\" \"tar tzvf -\""
+               --exclude-from=/root/.backup/exclude\" | pee \"cat > $TARFILE\" \"tar tzvf -\""
        echo `date`" $computer: Running $TARCMD" >&2
        eval $TARCMD > $DATE.idx
 
@@ -184,34 +181,34 @@ filesystems=`ssh -n root@$computer "cat /etc/fstab" \
        | awk '{ if ( $(NF-1) != "0" ) print $2}' `
 
 # Clean up our dir at this client
-if ! ssh root@$computer "rm -r ~/.backup ; mkdir -m 700 ~/.backup"; then
-       echo `date`" $computer: Could not create backup staging area at $computer:~/.backup"
+if ! ssh root@$computer "rm -r /root/.backup ; mkdir -m 700 /root/.backup"; then
+       echo `date`" $computer: Could not create backup staging area at $computer:/root/.backup"
        die
 fi
 
 # Try to copy $exclude to $computer
-if ! scp $exclude root@$computer:~/.backup/exclude > /dev/null; then
+if ! scp $exclude root@$computer:/root/.backup/exclude > /dev/null; then
        echo `date`" $computer: Could not copy exclude.txt to $computer"
        die
 fi
 
 # Try to copy preeexec and postexec if they exist
 if [ -f $confdir/preexec.$computer ]; then
-       if ! scp $confdir/preexec.$computer  root@$computer:~/.backup/preexec >&2; then
-               echo `date`" $computer: Could not copy preexec.$computer to $computer:~/.backup/preexec"
+       if ! scp $confdir/preexec.$computer  root@$computer:/root/.backup/preexec >&2; then
+               echo `date`" $computer: Could not copy preexec.$computer to $computer:/root/.backup/preexec"
                die
        fi
 fi
 if [ -f $confdir/postexec.$computer ]; then
-       if ! scp $confdir/postexec.$computer root@$computer:~/.backup/postexec >&2; then
-               echo `date`" $computer: Could not copy postexec.$computer to $computer:~/.backup/postexec"
+       if ! scp $confdir/postexec.$computer root@$computer:/root/.backup/postexec >&2; then
+               echo `date`" $computer: Could not copy postexec.$computer to $computer:/root/.backup/postexec"
                die
        fi
 fi
 
 # Try to run preexec if it exists
-if ! ssh root@$computer "[ ! -f ~/.backup/preexec ] || /bin/bash -x ~/.backup/preexec" >&2; then
-       echo `date`" $computer: Could not run $computer:~/.backup/preexec"
+if ! ssh root@$computer "[ ! -f /root/.backup/preexec ] || /bin/bash -x /root/.backup/preexec" >&2; then
+       echo `date`" $computer: Could not run $computer:/root/.backup/preexec"
        die
 fi
 
@@ -285,8 +282,8 @@ do
 done
 
 # Try to run postexec if it exist
-if ! ssh root@$computer "[ ! -f ~/.backup/postexec ] || /bin/bash -x ~/.backup/postexec" >&2; then
-       echo `date`" $computer: Could not run $computer:~/.backup/postexec"
+if ! ssh root@$computer "[ ! -f /root/.backup/postexec ] || /bin/bash -x /root/.backup/postexec" >&2; then
+       echo `date`" $computer: Could not run $computer:/root/.backup/postexec"
        die
 fi