SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
running script before job fails due to permission issue
Author Message
Post running script before job fails due to permission issue 
When logged on as root, I can run the following script to backup my MySQL databases to a local folder:

#!/bin/bash


BACKUPLOCATION=/var/local/mysqlbackups
LOGFILE=/usr/local/sbin/backupdbs.log
GZIP="$(which gzip)"
NOW=$(date +"%d-%m-%Y")
RETENTION=30
#remove .gz files greater than 30 days old
find /var/local/mysqlbackups -mtime +$RETENTION -exec rm -fr {} ; &> /dev/null
# back up all the mysql databases, into individual files so we can later restore
# them separately if needed.
mysql --defaults-extra-file=/root/.my.cnf -B -N -e "show databases" | while read db
do
   BACKUPFILE=$BACKUPLOCATION/mysql-${db}.${NOW}-$(date +"%T").gz
   echo "Backing up $db into $BACKUPFILE"
   /usr/bin/mysqldump --defaults-extra-file=/root/.my.cnf --single-transaction $db | $GZIP -9 > $BACKUPFILE
done >>$LOGFILE



However, when I run the backup from bacula, I get the following error message...


The backup job is now running. When complete, the results will be shown below .. 05-Apr 16:18 cablemon-dir JobId 27: shell command: run BeforeJob "/usr/local/sbin/backupdbs"
05-Apr 16:18 cablemon-dir JobId 27: BeforeJob: Could not open required defaults file: /root/.my.cnf
05-Apr 16:18 cablemon-dir JobId 27: BeforeJob: Fatal error in defaults handling. Program aborted
05-Apr 16:18 cablemon-dir JobId 27: BeforeJob: ERROR 1045 (28000): Access denied for user 'bacula' < at > 'localhost' (using password: NO)
05-Apr 16:18 cablemon-dir JobId 27: Start Backup JobId 27, Job=BackupClient1.2012-04-05_16.18.54_33
05-Apr 16:18 cablemon-dir JobId 27: Using Device "FileStorage"
05-Apr 16:18 cablemon-sd JobId 27: Volume "Inc-0002" previously written, moving to end of data.
05-Apr 16:18 cablemon-sd JobId 27: Ready to append to end of Volume "Inc-0002" size=67985900
05-Apr 16:18 cablemon-fd JobId 27: Could not stat "/usr/sbin/local": ERR=No such file or directory
05-Apr 16:18 cablemon-sd JobId 27: Job write elapsed time = 00:00:01, Transfer rate = 0 Bytes/second
05-Apr 16:18 cablemon-dir JobId 27: Bacula cablemon-dir 5.0.1 (24Feb10): 05-Apr-2012 16:18:57The backup finishes ok, just not the script component. I first gave read access to /root/.my.cnf for the account "bacula", but I still got the error. I even set the permissions as 777 for .my.cnf and still I got the above error. I am using the .my.cnf file to hide the mysql username and password.

Post running script before job fails due to permission issue 
On 04/05/2012 07:27 PM, Murray Davis wrote:
When logged on as root, I can run the following script to backup my
MySQL databases to a local folder:

[...]

05-Apr 16:18 cablemon-dir JobId 27: shell command: run BeforeJob "/usr/local/sbin/backupdbs"
05-Apr 16:18 cablemon-dir JobId 27: BeforeJob: Could not open required defaults file: /root/.my.cnf

What user does bacula run as?


--
Phil Stracchino, CDK#2 DoD#299792458 ICBM: 43.5607, -71.355
alaric < at > caerllewys.net alaric < at > metrocast.net phil < at > co.ordinate.org
Renaissance Man, Unix ronin, Perl hacker, SQL wrangler, Free Stater
It's not the years, it's the mileage.

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Bacula-users mailing list
Bacula-users < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Post running script before job fails due to permission issue 
As Martin S. suggested, I ended up moving the script to /etc/bacula and the bacula was able to run the script before the job ran...which still seems strange given that the permissions were the same in the /root directory as in the /etc/bacula directory.

Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


Magic SEO URL for phpBB