I have a crontab job that call a simple script to backup a website:
15 0 1,10,20 * * /home/username/bin/backup_whatever
This is the script:
#!/bin/bash
TODAY=$(date +"%Y%m%d")
FILE_TO_PUT="filename.$TODAY.tar.gz"
rm -rf /home/username/filename.tar.gz
tar -zcvf /home/username/filename.tar.gz -C / var/www/website/
s3cmd put /home/username/filename.tar.gz s3://s3bucket/backups/$FILE_TO_PUT
As the tar command compress lots of files, the email I got when this is executed is really huge. How can I do to just display a message like compression successfully instead the full output of tar command?
Will be ok, if I do something like this? Can't find out the tar return codes.
EXITCODE=$(tar -zcvf /home/username/filename.tar.gz -C / var/www/website/)
if [ $EXITCODE -eq 0]
then
echo "compression successfully"
else
echo "compression unsuccessfully"
fi
Aucun commentaire:
Enregistrer un commentaire