#!/bin/bash TAR=/usr/bin/tar PYTHON=/usr/bin/python3 GZIP=/usr/bin/gzip SCRIPTDIR=/home/valentin/script/webscrap WEBSCRAP=${SCRIPTDIR}/import_export_canalblog.py URL=www.clarissariviere.com DATE=$(date +%Y%m%d) DIRECTORY=/home/valentin/backup BACKUPDIR=/home/valentin/backup_clarissa LIST=${BACKUPDIR}/backup.list fileBackup="backup-clarissa-${DATE}" LOGFILE=web_scrap.txt SENDER="valczebackup@gmail.com" if [ $(date +%u) -eq 5 ]; then echo > ${LIST} rm -rf "${BACKUPDIR}/*-incr.tar.gz" fileBackup="${fileBackup}-full" subject="Sauvegarde full" else fileBackup="${fileBackup}-incr" subject="Sauvegarde incremental" fi subject="${subject} ${URL} ${DATE}" echo > ${BACKUPDIR}/${LOGFILE} ${PYTHON} ${WEBSCRAP} --quiet --logfile ${BACKUPDIR}/${LOGFILE} --parallel 20 export --url ${URL} --directory ${DIRECTORY} if [ ${?} -ne 0 ]; then subject="${subject} echoue : recuperation page" echo ${subject} | mail -s "${subject}" -A ${BACKUPDIR}/${LOGFILE} ${SENDER} exit 1 fi ${TAR} --create --file="${BACKUPDIR}/${fileBackup}.tar" --listed-incremental=${LIST} ${DIRECTORY} if [ ${?} -ne 0 ]; then subject="${subject} echoue : archivage page " echo ${subject} | mail -s "${subject}" -A ${BACKUPDIR}/${LOGFILE} ${SENDER} exit 1 fi ${GZIP} -f -9 "${BACKUPDIR}/${fileBackup}.tar" if [ ${?} -ne 0 ]; then subject="${subject} echoue : compression archive " echo ${subject} | mail -s "${subject}" -A ${BACKUPDIR}/${LOGFILE} ${SENDER} exit 1 fi subject="${subject} OK" echo ${subject}| mail -s "${subject}" -A ${BACKUPDIR}/${LOGFILE} ${SENDER} exit 0