Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: thedude 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????
-
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
-
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/
-
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
-
not too far off topic, I hope...
It does seem to be a long way off topic. :-)
-
oh well, I tried :-)
-
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!!
;)
-
Ron,
I just noticed that you are in Nevada City. I live in Grass Valley.
Small World
Chris
-
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
-
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!
-
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
-
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.
-
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!!