[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 # 3 4 # 5 # $Id: restorebackup.sh 8418 2015-01-27 23:57:30Z keyser $ 6 # 7 8 9 # Verifie le point de montage du peripherique de backup 10 # bpcmedia=1 --> disque USB 11 # bpcmedia=2 --> disque dur 12 # bpcmedia=3 --> NAS 13 . /usr/share/se3/includes/config.inc.sh -b 14 15 16 17 if [ -e "/etc/backuppc/restore.lck" ]; then 18 exit 0 19 fi 20 21 ps auxw | grep fsck | grep -v grep && exit 0; 22 # 23 # if [ -e /var/www/se3/includes/config.inc.php ] 24 # then 25 # dbhost=`cat /var/www/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f 2 |cut -d \" -f 2` 26 # dbname=`cat /var/www/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2` 27 # dbuser=`cat /var/www/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 |cut -d \" -f 2` 28 # dbpass=`cat /var/www/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 |cut -d \" -f 2` 29 # else 30 # echo "impossible d'acceder aux params mysql" 31 # exit 1 32 # fi 33 34 # bpcmedia=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='bpcmedia'"` 35 # bck_user=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='bck_user'"` 36 # usbdisk=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='usbdisk'"` 37 USBDEV=/dev/disk/by-id/$usbdisk 38 # 39 # Disque USB 40 # 41 42 if [ "$bpcmedia" = "1" ]; then 43 44 mount |grep "\/var\/lib\/backuppc" >/dev/null || MBPC=0 45 if [ "$MBPC" = "0" ]; then 46 echo "Disque USB non monté." 47 echo "Détection du disque, veuillez patienter..." 48 /etc/init.d/backuppc stop > /dev/null 49 sleep 1 50 ps auxw |grep backuppc | grep $bck_user | grep -v grep >/dev/null && killall -9 "/usr/bin/perl" 51 if [ ! -z "$USBDEV" ]; then 52 echo "Disque $USBDEV détecté" 53 sleep 1 54 mount $USBDEV}-part1 /var/lib/backuppc 55 if [ "$?" != "0" ]; then 56 fsck.ext3 -y $USBDEV}-part1 57 mount $USBDEV}-part1 /var/lib/backuppc 58 fi 59 fi 60 fi 61 mount |grep "\/var\/lib\/backuppc" >/dev/null || EXIT1=1 62 touch /var/lib/backuppc/test 2&> /dev/null || TBPC=0 63 if [ "$TBPC" = "0" ]; then 64 echo "Impossible d'écrire sur le disque USB" 65 /etc/init.d/backuppc stop > /dev/null 66 sleep 1 67 ps auxw |grep backuppc | grep $bck_user | grep -v grep >/dev/null && killall -9 "/usr/bin/perl" 68 umount /var/lib/backuppc 69 echo "Détection du disque, veuillez patienter..." 70 if [ ! -z "$USBDEV" ]; then 71 echo "Disque $USBDEV détecté" 72 sleep 1 73 mount $USBDEV}-part1 /var/lib/backuppc 74 if [ "$?" != "0" ]; then 75 fsck.ext3 -y $USBDEV}-part1 76 mount $USBDEV}-part1 /var/lib/backuppc 77 fi 78 fi 79 fi 80 mount |grep "\/var\/lib\/backuppc" >/dev/null || EXIT1=1 81 touch /var/lib/backuppc/test 2&> /dev/null || EXIT1=1 82 if [ "$EXIT1" = 1 ]; then 83 echo "Impossible de remettre en route le disque USB" 84 echo "Impossible de remettre en route le disque USB" | mail -s "Erreur sauvegarde se3" root 85 /etc/init.d/backuppc stop > /dev/null 86 sleep 5 87 ps auxw |grep backuppc | grep $bck_user | grep -v grep >/dev/null && killall -9 "/usr/bin/perl" 88 exit 1 89 fi 90 91 fi 92 93 # 94 # NAS 95 # 96 97 if [ "$bpcmedia" = "3" ]; then 98 mount |grep "\/var\/lib\/backuppc" >/dev/null || MBPC=0 99 if [ "$MBPC" = "0" ]; then 100 echo "NAS non monté." 101 # Recuperation des parametres 102 # NAS_protocol=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_protocol'"` 103 # NAS_ip=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_ip'"` 104 # NAS_share=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_share'"` 105 # NAS_login=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_login'"` 106 # NAS_pass=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_pass'"` 107 # NAS_mntsuffix=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='NAS_mntsuffix'"` 108 # BPCUIDN=`mysql se3db -u $dbuser -p$dbpass -B -N -e "select value from params where name='bck_uidnumber'"` 109 # BPCUIDN=`getent passwd www-se3| cut -d : -f3` 110 111 if [ ! -d /var/lib/backuppc/$NAS_mntsuffix ]; then 112 mkdir -p /var/lib/backuppc/$NAS_mntsuffix 113 fi 114 115 if [ "$NAS_protocol" = "cifs" ]; then 116 # Montage du NAS en CIFS 117 mount.cifs //$NAS_ip/$NAS_share /var/lib/backuppc/$NAS_mntsuffix -o username=$NAS_login,password=$NAS_pass,ip=$NAS_ip,uid=$BPCUIDN 118 #echo "mount.cifs //$NAS_ip/$NAS_share /var/lib/backuppc/$NAS_mntsuffix -o username=$NAS_login,password=$NAS_pass,ip=$NAS_ip,uid=$BPCUIDN" 119 sleep 3 120 elif [ "$NAS_protocol" = "nfs" ]; then 121 # Montage du NAS en NFS 122 mount -t nfs $NAS_ip:$NAS_share /var/lib/backuppc/$NAS_mntsuffix 123 #echo "mount -t nfs $NAS_ip:$NAS_share /var/lib/backuppc/$NAS_mntsuffix" 124 sleep 3 125 mount |grep "type nfs" | grep backuppc || (mount -t nfs4 $NAS_ip:$NAS_share /var/lib/backuppc/$NAS_mntsuffix ; sleep 3) 126 fi 127 fi 128 129 mount |grep "\/var\/lib\/backuppc" >/dev/null || EXIT1=1 130 touch /var/lib/backuppc/$NAS_mntsuffix/test 2&> /dev/null || TBPC=0 131 if [ "$TBPC" = "0" ]; then 132 echo "Impossible d'écrire sur le partage NAS" 133 /etc/init.d/backuppc stop > /dev/null 134 sleep 5 135 ps auxw |grep backuppc | grep $bck_user | grep -v grep >/dev/null && killall -9 "/usr/bin/perl" 136 #umount /var/lib/backuppc/$NAS_mntsuffix 137 exit 1 138 fi 139 if [ "$EXIT1" = 1 ]; then 140 echo "Impossible de remettre en route le partage NAS" 141 echo "Impossible de remettre en route le partage NAS" | mail -s "Erreur sauvegarde se3" root 142 /etc/init.d/backuppc stop > /dev/null 143 sleep 5 144 ps auxw |grep backuppc | grep $bck_user | grep -v grep >/dev/null && killall -9 "/usr/bin/perl" 145 exit 1 146 fi 147 148 fi 149 150 [ ! -d /var/lib/backuppc/pc ] && mkdir /var/lib/backuppc/pc 151 [ ! -d /var/lib/backuppc/cpool ] && mkdir /var/lib/backuppc/cpool 152 153 # 154 # Demarrage de backuppc 155 # 156 /etc/init.d/backuppc restart || ( 157 /usr/share/se3/sbin/permbackuppc 158 /etc/init.d/backuppc start 159 )
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |