web_scrap/backup_canalblog.sh

48 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2023-03-09 23:06:34 +01:00
#!/bin/bash
TAR=/usr/bin/tar
PYTHON=/usr/bin/python3
GZIP=/usr/bin/gzip
2023-05-24 23:34:03 +02:00
SCRIPTDIR=/home/valentin/script/webscrap
WEBSCRAP=${SCRIPTDIR}/import_export_canalblog.py
2023-03-09 23:06:34 +01:00
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}
2023-05-24 23:34:03 +02:00
${PYTHON} ${WEBSCRAP} --quiet --logfile ${BACKUPDIR}/${LOGFILE} --parallel 20 export --url ${URL} --directory ${DIRECTORY}
if [ ${?} -ne 0 ]; then
2023-03-09 23:06:34 +01:00
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