I've been having issues with cron and a backup script that I've been using. Here is the script below
Code:
#!/bin/sh
################################################################################
###### Variables ######
time=$(date +%Y%m%d)
numFiles=$(ls /backup/system/FreeLSD | wc -l)
launchBackup=$(exec tar -cvjf /backup/system/FreeLSD/$time.FreeLSD.systembackup.tar.bz2 --exclude=/backup --exclude=/proc --exclude=/tmp --exclude=/ftp --exclude=/mnt /)
oldestBackup=$(ls /backup/system/FreeLSD | sort -n | head -1)
################################################################################
###### Action! ######
if [ $numFiles -gt 2 ] ; then
rm /backup/system/FreeLSD/$oldestBackup
else
exec $launchBackup && du -m /backup/system/FreeLSD/* | mail -s AutoBackup example@foomail.com
fi
And here is the entry of the offending script in my crontab
Code:
################################################################################
#minute hour mday month wday who command
################################################################################
#Automatically backs up the local filesystem into the backups directory with tar
23 1 * * * root /root/scripts/autobackup.sh
The script does run at the specified time and seems to function except for the fact that when it's run from cron, it only backs up approximately 130 MB of data. When it is run from a shell it performs the full backup. Here's a comparison of the script, the ones with the larger value were run from the shell, and the smaller ones were run by cron.
Code:
143 /backup/system/FreeLSD/20110404.FreeLSD.systembackup.tar.bz2
10686 /backup/system/FreeLSD/20110405.FreeLSD.systembackup.tar.bz2
68 /backup/system/FreeLSD/20110409.FreeLSD.systembackup.tar.bz2
Any ideas as to why this is happening?