Skip to content

Commit

Permalink
Ajout d'une vérification au niveau de la taille de l'archive
Browse files Browse the repository at this point in the history
  • Loading branch information
hardware committed Oct 13, 2014
1 parent ad26fa1 commit e0154bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ fi

echo -e " ${CGREEN}[OK]${CEND}" | tee -a $LOG_FILE

# Récupère la taille de l'archive en octets
SIZE=$(wc -c $ARCHIVE | cut -f 1 -d ' ')
HUMANSIZE=$(echo ${SIZE} | awk '{ sum=$1 ; hum[1024**3]="Go";hum[1024**2]="Mo";hum[1024]="Ko"; \
for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } }}')

# 2147483648 = 2GB = 2Go
if [ $SIZE -gt 2147483648 ]; then
echo -e "\n${CRED}/!\ ATTENTION: L'archive est très volumineuse ( $HUMANSIZE )${CEND}" | tee -a $LOG_FILE
echo -e "\n${CRED}/!\ Vous devriez exclure d'avantage de répertoires dans le fichier d'exclusion.${CEND}" | tee -a $LOG_FILE
echo -e "" | tee -a $LOG_FILE
sendErrorMail "Archive trop volumineuse ( $HUMANSIZE ), merci de vérifier le fichier d'exclusion."
fi

# On vérifie que le fichier .gpg-passwd existe bien
if [ ! -f /opt/full-backup/.gpg-passwd ]; then
echo -e "\n${CRED}/!\ ERREUR: Le fichier${CEND} ${CPURPLE}/opt/full-backup/.gpg-passwd${CEND} ${CRED}n'existe pas !${CEND}" | tee -a $LOG_FILE
Expand Down

0 comments on commit e0154bc

Please sign in to comment.