X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=backup.sh;h=20a26f955d658fade5912bd667983cb6b68e89eb;hb=3870092139e235a69ca81ef8c2dd0739041a5d9a;hp=3244d75afd9e6d39bf1093948ff28b3e1a7198e7;hpb=a2dd914e32d8dac8211988319ccdabcbe8d62241;p=backup.sh diff --git a/backup.sh b/backup.sh index 3244d75..20a26f9 100755 --- a/backup.sh +++ b/backup.sh @@ -2,7 +2,6 @@ #dirs confdir=/home/backup/conf/ #configuration files -webdir=/home/backup/public_html #web-pages storagedir=/backup #mountpoint of huge disc ### @@ -35,7 +34,6 @@ unixcomputers=`cat $confdir/computers.unix` ### #disse bør kunne varieres fra fs til fs? -#disse bør flyttes ut i egen fil som kan editeres fra web kanskje? maksantallfulle=2 #hvor mange fulle vi tar vare på dagermellomfulle=30 #antall dager før det er på tide med ny full logw=40 @@ -56,22 +54,31 @@ backup() if [ "$backuplevel" = "daglig" ] || [ "$backuplevel" = "incremental" ] then - forrige=`cat ../.date` - forrigecmd="--newer=\"$forrige\"" + lastd=`cat ../.date` + lastcmd="--newer=\"$lastd\"" else - forrigecmd="" + lastcmd="" fi - #Prøver å ta backup med tar + #if this client has a special tar + #we need to find a better solution to this conf-issue + if [ -f $confdir/tar.$computer ] ; then + tar=`cat $confdir/tar.$computer` + else + tar=tar + fi + + #We try to run tar on the remote computer if `ssh $computer "cd $filesystem ;\ - tar cfl - . $forrigecmd \ + $tar cfl - . $lastcmd \ --exclude-from=/tmp/.backup/exclude \ | gzip" \ | dd of=$DATE.tmp 2>/dev/null` then #perhaps it did work mv $DATE.tmp $DATE.tgz - #make a filelist and update the datefile + #make a filelist. + #update the datefile if the filelist is ok. tar tvfz $DATE.tgz > $DATE.idx 2>&1 && echo $DATEs > ../.date && touch -t $DATE ../.date @@ -80,8 +87,8 @@ backup() grep -v ^d $DATE.idx | sort -n -r +2 > $DATE.sdx #fix perm - chmod 600 *tgz - chmod 644 *sdx *idx 2>/dev/null + chmod 600 *tgz #only for us + chmod 644 *sdx *idx 2>/dev/null #everyone can read else #it did not work @@ -109,7 +116,7 @@ do #try to copy $exclude to $computer scp $exclude $computer:/tmp/.backup/exclude || - echo "Vi klarte ikke kopiere over exclude.txt til $computer :(" + echo "could not copy exclude.txt to $computer :(" #try to copy preeexec and postexec if they exist [ -f $confdir/preexec.$computer ] && @@ -118,8 +125,7 @@ do scp $confdir/postexec.$computer $computer:/tmp/.backup/postexec #try to run preexec if it exist - ssh $computer "[ -f /tmp/.backup/preexec ] && - /bin/bash -x /tmp/.backup/preexec" + ssh $computer "[ -f /tmp/.backup/preexec ] && /bin/bash -x /tmp/.backup/preexec" for filesystem in $filesystems do @@ -178,8 +184,7 @@ do done #try to run postexec if it exist - ssh $computer "[ -f /tmp/.backup/postexec ] && - /bin/bash -x /tmp/.backup/postexec" + ssh $computer "[ -f /tmp/.backup/postexec ] && /bin/bash -x /tmp/.backup/postexec" done