add script backup canalblog
This commit is contained in:
parent
dfc9c4277b
commit
a6d642811e
47
backup_canalblog.sh
Executable file
47
backup_canalblog.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
TAR=/usr/bin/tar
|
||||
PYTHON=/usr/bin/python3
|
||||
GZIP=/usr/bin/gzip
|
||||
SCRIPTDIR=/home/valentin/script
|
||||
WEBSCRAP=${SCRIPTDIR}/web_scrap.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} --url ${URL} --dir ${DIRECTORY} --quiet --logfile ${BACKUPDIR}/${LOGFILE}
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user