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

The great mistery of the empty tar.bz2 file

Nihil sine backup, and what better way to do backup than a script placed in crontab? The script is a simple one:

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

It dumps MySQL database in a folder than group a few folders in an archive with a proper name based on the date and time of its creation and finally cleans up. Nothing fancy, just your basic backup script. Running it by hand will start tar.bz2-ing the files and then carefully place the archive where it should. Nothing extraordinary here, just a script doing its job.

The problems appears when I place the script in crontab.

50 3 * * 3 /bin/sh /root/

As expected, the script starts running when it should, but fails when it reaches the first file on the first folder that it needs to process. The resulted tar.bz2 file is in its right place, but it’s empty, with a size of 0 KB. Yes, the script is executable, like I said, running it by hand gives the expected behavior and results. I suspect some sort of permissions issue, but I couldn’t find a way to solve this yet. Until then, manual backup will do the job.

Edit: Problem fixed. See here.

  1. zerobsd posted this
blog comments powered by Disqus