]> git.sesse.net Git - backup.sh/blobdiff - backup.sh
*** empty log message ***
[backup.sh] / backup.sh
index ecf9819eab0251cba06d14e722a26963893a0cd1..49a643d87c29de676af1b9adeefeeff7daa83d77 100755 (executable)
--- 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,28 @@ 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
+ $tar=${TAR:-tar}
+ unset TAR
+
+ #We try to run tar on the remote computer
+ #need to specify a special tar on some clients. how?
  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 +84,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 +113,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 +122,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
@@ -130,8 +133,8 @@ do
   mkdir -m 755 -p $storagedir/$computer/$sfilesystem/{full,daglig} 2>/dev/null
 
   #
-  echo $filesystem > $storagedir/$computer/$sfilesystem.name
-  chmod 644 $storagedir/$computer/$sfilesystem.name
+  echo $filesystem > ${storagedir}/${computer}/.${sfilesystem}.name 
+  chmod 644 ${storagedir}/${computer}/.${sfilesystem}.name
 
   #set default backuplevel
   backuplevel=daglig
@@ -178,8 +181,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