ZeroBSD

A n00b's adventure in the wonderful realm of BSD.

Empty tar.bz2 file (follow-up)

Remember this problem I had? Well, thanks to Andrei Mureșan, it’s fixed now. Apparently, cron has no idea of environmental variables when running the backup script, so I had to add the following line at the begining of my script:

PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:.

Works like a charm now. For future reference, he’s the full, corrected and working backup script:

PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:.
NOWD=$(date +”%F”)
NOWT=$(date +”%T”)
/usr/local/bin/mysqldump -u root -password \
dbname > /root/databases/db.sql
/bin/tar cvfj /home/john/backup/backup-$NOWD-$NOWT.tar.bz2 \
/var/log /var/www /etc /root/databases
/bin/rm /root/databases/db.sql

  1. zerobsd posted this
blog comments powered by Disqus