[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cron fails running Rsync (rsnapshot) Script

Posted on 2007-08-08
15
Medium Priority
?
997 Views
Last Modified: 2013-12-01
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
0
Comment
Question by:drasche
  • 8
  • 7
15 Comments
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19658357
It seems that root should receive a mail about the failing cron.  Have you received any?
0
 

Author Comment

by:drasche
ID: 19658411
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
 
LVL 29

Accepted Solution

by:
Jan Springer earned 2000 total points
ID: 19658586
Well, I use sendmail and could help you there.  The others (qmail, postfix, exim) I am not familiar with at all.
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 

Author Comment

by:drasche
ID: 19658669
Wouldn't any message that cron creates show up in the messages log, syslog, etc....
0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19658800
In your log directory, you may have a file called 'cron.log'.  If so, it may provide some insight.
0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19658814
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
 

Author Comment

by:drasche
ID: 19663729
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
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19664487
okay, that's a different problem.

what is the exact rsync command that is failing?
0
 

Author Comment

by:drasche
ID: 19664837
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
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19665309
Is this command embedded within the perl rsnapshot script?

If so, what is "E$/account"?
0
 

Author Comment

by:drasche
ID: 19665441
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
 
LVL 29

Expert Comment

by:Jan Springer
ID: 19665855
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
 

Author Comment

by:drasche
ID: 19665936
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
 

Author Comment

by:drasche
ID: 19666608
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
 

Author Comment

by:drasche
ID: 19676398
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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question