From fcaca869b136cd3e3dc1de69c3d0b67fb565653a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 5 Oct 2014 00:41:53 +0200 Subject: [PATCH] Always assume /root exists for root, instead of trying to go through hoops to expand ~. --- backup.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/backup.sh b/backup.sh index 5c240aa..075f89a 100755 --- 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 -- 2.39.2