Koozali.org: home of the SME Server

Strange problem

thedude

Strange problem
« on: July 15, 2005, 06:12:36 PM »
I'm trying to run a mysql backup that simply does a dump and puts the results into a directory. Here is the script:

#!/bin/sh
mysqldump -u root -p******(mysql password) --all-databases > /home/e-smith/files/ibays/Primary/files/backup/backup.sql
cat file | mail myemail@hotmail.com -s "Backup Successful"

Now, if I run that script from command line, it runs just fine. The backup is done, the sql file appears where it should, and I get the email.

What I can't get to happen is for cron to be able to run this script. I have the cron job setup, it runs. I can see that in the cron logs.

Jul 14 23:30:00 SMESERVERNAME CROND[13856]: (root) CMD (root /home/e-smith/files/ibays/Primary/files/backup/backup.sh)

But no backup happens, and of course no error messages that I can pin this on. I have all the proper permissions set, owners, and group. They are all set to 755 or even 777, and the file is owned by root. The cron job is set to run as root. Here is the cron job:

30 23 * * * root /home/e-smith/files/ibays/Primary/files/backup/backup.sh

And, like I said, if I run it from the command line it runs just fine.

What the heck am I missing????

gardnc

Strange problem
« Reply #1 on: July 18, 2005, 12:06:39 AM »
thedude,

In the cron I don't think

root /home/e-smith/files/ibays/Primary/files/backup/backup.sh  

is a valid path,

shouldn't it be
 

/home/e-smith/files/ibays/Primary/files/backup/backup.sh

(unless, of course you have created that odd path)
Larry

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Strange problem
« Reply #2 on: July 18, 2005, 03:32:58 AM »
Quote from: "thedude"
I'm trying to run a mysql backup that simply does a dump and puts the results into a directory.


/sbin/e-smith/signal-event pre-backup

See results by:

ls /home/e-smith/db/mysql/

RonM

Strange problem
« Reply #3 on: July 18, 2005, 06:19:44 AM »
not too far off topic, I hope...

this reminds me of a question I had when v5.6 came out.

Is there an issue with cron issueing a command as root

or with cron sending an email as root?

I had a similar issue trying to email myself the results of a scheduled vscan, command worked fine on 5.5, and also when I removed the email portion.

RonM

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Strange problem
« Reply #4 on: July 18, 2005, 04:48:35 PM »
Quote from: "RonM"
not too far off topic, I hope...


It does seem to be a long way off topic. :-)

RonM

Strange problem
« Reply #5 on: July 18, 2005, 05:23:35 PM »
oh well, I tried :-)

thedude

Strange problem
« Reply #6 on: July 18, 2005, 06:26:15 PM »
gardnc,
That root, is telling the cron to run the script as root.
---------

Charlie,
I did what you said and the only thing in the mysql.dump file was the word "flush privileges".

I'd rather my script would run. I like the email notification because this is a remote client server, and I have a backup scheduled from another computer to grab the results of the script.

It just doesn't make any sense why it doesn't work. Just fyi, the email thing is new, it didn't work before the email part, so that didn't break it.

-----
Ron,
No thread hijacking, get your own!!
;)

thedude

Strange problem
« Reply #7 on: July 18, 2005, 06:30:46 PM »
Ron,
I just noticed that you are in Nevada City. I live in Grass Valley.

Small World

Chris

boss_hog

Strange problem
« Reply #8 on: July 18, 2005, 07:41:59 PM »
Hey thedude,
could I suggest a third party, opensource option?
I use this nifty little script here: http://sourceforge.net/projects/automysqlbackup/
It is very small and easy to setup.

It can be configured in a few different ways. I use it to email my DB's to myself so I always have an off-site backup.
Hope this can help.
Joe

thedude

Strange problem
« Reply #9 on: July 18, 2005, 08:13:13 PM »
Well thanks but there really isn't a need for a complex script, and what I have is already an sh script. The script I have is literally 3 lines long:

#!/bin/sh
mysqldump -u root -mysqlpassword --all-databases > /home/e-smith/files/ibays/Primary/files/backup/backup.sql
cat /home/e-smith/files/ibays/Primary/files/backup/file | mail email@domain.com -s "Backup Successful"

It works just great. As long as I log in and type sh backup.sh

I just can't get the server to run it!!

Arrgh!

RonM

Strange problem
« Reply #10 on: July 18, 2005, 08:28:24 PM »
Quote from: "thedude"
Ron,
I just noticed that you are in Nevada City. I live in Grass Valley.

Small World

Chris


Cool, we'll have to pop down and see whether one of the batches of Nevada City Ale tastes like ambrosia, or rancid orange peel ;-)

About the script, have you tried to trigger it with cron but without the pipe to email command? That's actually what I was wondering earlier...

RonM

thedude

Strange problem
« Reply #11 on: July 18, 2005, 09:03:50 PM »
Beer sounds good right now, very good.

As for the email part, the script still didn't run before I put that in.

I've tried something else. In my cronjob I put sh before the path to the sh script. Since the dang thing runs just fine for me at command line (even the email part) when I type sh backup.sh I figured what the hell give it a shot.

thedude

Strange problem
« Reply #12 on: July 19, 2005, 04:32:55 PM »
Well, adding the sh to the cron job made all the difference. The backup now runs. Thanks for all the help.

For anyone else looking for a really simple mysql backup, that emails you upon success, go ahead and use it. Just be sure you put the sh in the cron job!!