[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-backup/usr/share/se3/sbin/ -> testbackup.sh (source)

   1  #!/bin/bash
   2  
   3  #
   4  ## $Id: testbackup.sh 8409 2015-01-26 00:24:49Z keyser $ ##
   5  #
   6  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
   7  
   8  
   9  #init params bdd
  10  . /usr/share/se3/includes/config.inc.sh -b
  11  
  12  if [ "$1" = "--help" -o "$1" = "-h" ]
  13  then
  14      echo "Test si le disque de sauvegarde est monte"
  15      echo "Usage : aucune option"
  16      exit
  17  fi
  18  
  19  function free_space
  20  {
  21  libre=$(($(stat -f --format="%a*%S/1048576" /var/lib/backuppc))) 
  22  if [ "$libre" -lt 15000 ];then
  23      echo "Espace insuffisant sur /var/lib/backuppc : $libre Mo"
  24      EXIT1=1
  25  fi
  26  }
  27  
  28  function stop_service
  29  {
  30  echo "Arret du service backuppc"
  31  /usr/share/se3/scripts/startbackup stop
  32  exit 1
  33  }
  34  
  35  function test_media
  36  {
  37  
  38  if [ "$bpcmedia" = "0" ]; then
  39              # on teste le chemin
  40              CHEMIN_SAV="/var/lib/backuppc"
  41              [ -h "$CHEMIN_SAV" ] && CHEMIN_SAV=$(readlink -e /var/lib/backuppc)
  42              df |grep "$CHEMIN_SAV" >/dev/null || MBPC=0
  43              if [ "$MBPC" = "0" ]; then
  44                  echo "Aucune partition montee sur $CHEMIN_SAV"
  45                  EXIT1=1
  46              fi
  47              
  48              
  49  elif [ "$bpcmedia" = "1" ]; then
  50  ##### Teste si le disque USB est monte #####
  51      mount |grep "\/var\/lib\/backuppc" >/dev/null || MBPC=0
  52      if [ "$MBPC" = "0" ]; then
  53          echo "Disque USB non monte"
  54          EXIT1=1
  55      fi
  56      touch /var/lib/backuppc/test 2&> /dev/null || TBPC=0
  57      if [ "$TBPC" = "0" ]; then
  58          echo "Impossible d'ecrire sur le disque USB"
  59          EXIT1=1
  60      fi
  61      
  62      
  63  elif [ "$bpcmedia" = "3" ]; then
  64      
  65      ##### Test si le disque NAS est monte #####
  66      # NAS_mntsuffix=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_mntsuffix'"`
  67      # NAS_proto=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_proto'"`
  68      mount |grep "\/var\/lib\/backuppc" | grep "$NAS_protocol" >/dev/null || MBPC=0
  69      if [ "$MBPC" = "0" ]; then
  70          echo "Disque NAS non monte"
  71          EXIT1=1
  72      fi
  73      touch /var/lib/backuppc/$NAS_mntsuffix/test 2&1> /dev/null || TBPC=0
  74      if [ "$TBPC" = "0" ]; then
  75          echo "Impossible d'ecrire sur le disque NAS"
  76          EXIT1=1
  77      fi
  78      
  79  fi
  80  free_space
  81  }
  82  
  83  
  84  if [ "$1" = "cron" ]; then
  85      if [ -e  /var/run/backuppc/BackupPC.pid ]; then
  86          test_media
  87          [ "$EXIT1" = "1" ] && stop_service
  88      else
  89          if [ $backuppc = "1" ]; then
  90              if [ ! -e /tmp/alerte-backuppc ]; then
  91                  
  92                  echo "Attention, le module sauvegarde est actif mais le service backuppc est off"
  93                  touch /tmp/alerte-backuppc
  94                  EXIT1=1
  95              else
  96                  /usr/bin/find /tmp/ -maxdepth 1 -type f -name "alerte-backuppc" -ctime +1 -delete 
  97              fi
  98          fi    
  99      
 100      fi
 101  else
 102      test_media
 103      [ "$EXIT1" = "1" ] && exit 1
 104  fi
 105  
 106  
 107  
 108  
 109      
 110  exit 0


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1