Rsnapshot - Daily job runs manually fine, but fail with cron

Issues related to applications and software problems
Post Reply
bertalanimre
Posts: 140
Joined: 2015/06/02 13:04:03

Rsnapshot - Daily job runs manually fine, but fail with cron

Post by bertalanimre » 2015/07/03 10:26:55

Hello Boys!

My rsnapshot behaves very strange for me and I don't know the why and the solution neither.

I have made an rsnapshot config file for a remote servers backup. In it, there is a bash_script command which tells rsnapshot, to run this srcipt while backing up. Now comes the tricky part:
If I run the command:

Code: Select all

/usr/bin/rsnapshot -c /backup/configs/charm.conf daily
it runs smooth and fine.
I've added it to my crontab like:

Code: Select all

 08   11       *       *       *       /usr/bin/rsnapshot -c /backup/configs/charm.conf daily
and in the logs I can see that it fails at running the script declared in the config file.

Code: Select all

....
[03/Jul/2015:11:08:30] /usr/bin/rsnapshot -c /backup/configs/charm.conf daily: ERROR: backup_script /backup/scripts/charm.sh returned 255
...
[03/Jul/2015:11:08:30] /usr/bin/rsnapshot -c /backup/configs/charm.conf daily: ERROR: /usr/bin/rsync returned 255 while processing XY@SERVER.hu:/home/XY/sqldump/
...
What the hell? :D This annoys me because I want to order the remote servers to do a mysqldump from the backup server and not individually. For request, I OFC have all the logs and configs ready to upload.

lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Rsnapshot - Daily job runs manually fine, but fail with

Post by lightman47 » 2015/07/03 11:28:30

What happens if, after the final asterisk in your crontab, you insert " root"? (The user who is to run the job)

bertalanimre
Posts: 140
Joined: 2015/06/02 13:04:03

Re: Rsnapshot - Daily job runs manually fine, but fail with

Post by bertalanimre » 2015/07/03 12:59:20

lightman47 wrote:What happens if, after the final asterisk in your crontab, you insert " root"? (The user who is to run the job)
So you suggest my crontab should look like this?

Code: Select all

#MAILTO="" ##Supresses output
###MAILTO=me
###################################################################
#minute (0-59),                                                   #
#|    hour (0-23),                                                #
#|    |        day of the month (1-31),                           #
#|    |        |       month of the year (1-12),                  #
#|    |        |       |       day of the week (0-6 with 0=Sunday)#
#|    |        |       |       |       commands                   #
###################################################################
 08   11       *       *       *       /usr/bin/rsnapshot -c /backup/configs/charm.conf daily
 33   07       *       *       6       /usr/bin/rsnapshot -c /backup/configs/charm.conf weekly
 24   04       1       *       *       /usr/bin/rsnapshot -c /backup/configs/charm.conf monthly
" USERNAME"

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Rsnapshot - Daily job runs manually fine, but fail with

Post by MartinR » 2015/07/03 13:19:06

Watch out - there are two crontabs. The format for a user's crontab is as you have it:

Code: Select all

<min> <hour> <dom> <month> <dow> <command>
The system crontab in /etc/crontab (and /etc/crontab.d/...) is

Code: Select all

<min> <hour> <dom> <month> <dow> <user> <command>
lightman's suggestion was good if you are using the system cron tabs (which is more common these days), but would be wrong for a user's crontab.

bertalanimre
Posts: 140
Joined: 2015/06/02 13:04:03

Re: Rsnapshot - Daily job runs manually fine, but fail with

Post by bertalanimre » 2015/07/03 13:29:49

MADE IT!!!! This should be in the manual of rsnapshot or somewhere else. Here is thee answer:
I used the command:

Code: Select all

/usr/bin/rsnapshot -c /backup/configs/charm.conf daily
in my crontab

However, I've read that cron doesn't know anything about the environment, so I must use absolute path always. That's why I used /usr/bin/rsnapshot in the 1st place. Then it popped to my mind just now: I have to notify rsnapshot that everything after the /usr/bin/rsnapshot is an option for it, and not a separate action.

Code: Select all

/usr/bin/rsnapshot -c /backup/configs/charm.conf -v daily
The V was needed..... Tho I have no idea why.

Post Reply