Cron fails running Rsync (rsnapshot) Script

I am currently running a mixed environment of Ubuntu and Windows 2003 Servers in our office. We are using Rsnapshot on one of the Ubuntu machines to backup a local drive and a few windows folders on remote machines. Rsnapshot is an rotating rsync backup script. We have been using it for a number of years on a Debian machine successfully. We have the rsnapshot script set to run 6 times a day to get incremental backups using Cron. This is the problem. I can run the script from the command line (via sudo) and it completes successfully. When cron runs the job, it always fails. When it fails there are no error messages in any log to tell me what happened. It just stops running, leaving a stale .pid file which I need to manually delete in order to run the script.

Here is the cron file config:

drasche@server2:/var$ sudo crontab -l
Password:
# m h  dom mon dow   command
0 */4 * * *             /usr/bin/rsnapshot hourly
45 23 * * *             /usr/bin/rsnapshot daily
30 23 1,8,15,22 * *     /usr/bin/rsnapshot weekly
15 23 1 * *             /usr/bin/rnsapshot monthly
drascheAsked:
Who is Participating?
 
Jan SpringerCommented:
Well, I use sendmail and could help you there.  The others (qmail, postfix, exim) I am not familiar with at all.
0
 
Jan SpringerCommented:
It seems that root should receive a mail about the failing cron.  Have you received any?
0
 
drascheAuthor Commented:
I am not getting email from the system. How do you set that up? Ubuntu server install does not seem to set this up automatically.

I have repeatedly checked all of the log files for any information on Cron. I have even watched the processes fail using "top". The rsync command running can be easily sorted to the top of the list. Normally, the rsync command uses 2% -5% of the processor. When things start to go wrong, the rsync proccesses seem to go to sleep for a time then jump to 80% of the processor usages then fall back to 0% for awhile. Then they disappear. No error in any log.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
drascheAuthor Commented:
Wouldn't any message that cron creates show up in the messages log, syslog, etc....
0
 
Jan SpringerCommented:
In your log directory, you may have a file called 'cron.log'.  If so, it may provide some insight.
0
 
Jan SpringerCommented:
Hmmm.

This is a perl script.  I've always had to make a call to perl to run perl scripts from cron.

Try this:

0 */4 * * *             perl /usr/bin/rsnapshot hourly
45 23 * * *             perl /usr/bin/rsnapshot daily
30 23 1,8,15,22 * *     perl /usr/bin/rsnapshot weekly
15 23 1 * *             perl /usr/bin/rnsapshot monthly

And can you verify that /usr/bin/rsnapshop is set to executable?
0
 
drascheAuthor Commented:
rsnapshot is executable. It runs without a problem from the command line. My cron jobs follow the examples on from Rsnapshot. If I was to run

sudo /usr/bin/rsnapshot hourly

from the command line. It aways works. It is only failing from cron. Don't get me wrong. It starts running normally from cron. Just part way through one of the rsync commands, rsync just dissapears. Never reports an error or reports back to the script that it failed. Very weird.

I have no cron log. Is there a way to edit a config for cron to produce a log?
0
 
Jan SpringerCommented:
okay, that's a different problem.

what is the exact rsync command that is failing?
0
 
drascheAuthor Commented:
Here is one of the rsync commands from the log file. They all have the same options.

/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/E$/account /mnt/e1.1/rsnapshot/hourly.0/localhost/
0
 
Jan SpringerCommented:
Is this command embedded within the perl rsnapshot script?

If so, what is "E$/account"?
0
 
drascheAuthor Commented:
There is a config file for specifying options for the perl script. The the script builds the command. "E$/account is a mounted samba share. It is one of a number of samba shares that are being backed up. I am backing up one local drive and 4 samba shares. Here are all of the commands that it tries to run:

echo 30149 > /var/run/rsnapshot.pid
/bin/rm -rf /mnt/e1.1/rsnapshot/hourly.5/
mv /mnt/e1.1/rsnapshot/hourly.4/ /mnt/e1.1/rsnapshot/hourly.5/
mv /mnt/e1.1/rsnapshot/hourly.3/ /mnt/e1.1/rsnapshot/hourly.4/
mv /mnt/e1.1/rsnapshot/hourly.2/ /mnt/e1.1/rsnapshot/hourly.3/
mv /mnt/e1.1/rsnapshot/hourly.1/ /mnt/e1.1/rsnapshot/hourly.2/
/bin/cp -al /mnt/e1.1/rsnapshot/hourly.0 /mnt/e1.1/rsnapshot/hourly.1
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/project /mnt/e1.1/rsnapshot/hourly.0/localhost/
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/E$/account /mnt/e1.1/rsnapshot/hourly.0/localhost/
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/E$/FMSSQLBackup /mnt/e1.1/rsnapshot/hourly.0/localhost/
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/F$/bd /mnt/e1.1/rsnapshot/hourly.0/localhost/
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/F$/Users Shared Folders /mnt/e1.1/rsnapshot/hourly.0/localhost/
/usr/bin/rsync -av --delete --numeric-ids --relative --delete-excluded /mnt/server3/G$/mnt /mnt/e1.1/rsnapshot/hourly.0/localhost/
touch /mnt/e1.1/rsnapshot/hourly.0/
rm -f /var/run/rsnapshot.pid


This has worked in the past and does work being invoked from the command line, just not under the current setup via cron for some reason. It tends to fail on the second rsync jobs, but not always. I have had it fail on the first one (which is a local backup). I have also on a rare occasion had it fail on the third rsync job.

Right after it fails, I manually remove the .pid lock file and run it from the command line, and it works completely through.

I am setting up email to get the cron errors now and will report back what it says.
0
 
Jan SpringerCommented:
So, you have run the 'rsnaphot hourly'  perl script (for example) manually and it works without a problem?

Because my initial thought is that the perl script is trying to interpret the "$" as a variable.
0
 
drascheAuthor Commented:
Yes, everything works when I call the script from the command line as root (sudo). It is only when it is running in cron that it fails. I am running the script from cron as root. (just in case you were starting to think along those lines).

E$ is just part of the path I have setup. This has not been a problem before. Really, the rsync command starts, but disappears after awhile. I have watched it in with the "top" command and you can see it processing files. At some point, it just disappears.

I have the mail program running and cron is set to run in a few minutes. I'll let you know what, if any, error messages I get from cron.
0
 
drascheAuthor Commented:
I just let the cron job run again, and it completed without incident. I wonder if setting up the email cleared up the problem. I don't know why that would be, but if cron relies on it, then maybe that was the fix that was needed.

I am going to let it run a few more times and if it works, I'll close the question out.

-David
0
 
drascheAuthor Commented:
Once I got the mail program up and running, everything went smoothly. Turns out this script is trying to send a email through cron which includes everything that it did. Without access to email, cron eventually failed the jobs. Once that problem was solved, everything is running smoothly. Thanks for you help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.