Installation

cannot backup database with wwmysqldump

cannot backup database with wwmysqldump

by Ever Barbero -
Number of replies: 5
I have a problem following the instructions "Backup and Disaster Recovery" 
I got the .my.cnf to work as this
  [client]
  user=webworkWrite
  password="mydatabasepassword"
Now issuing these commands on the shell as follows
  $mysql webwork      lets me in w/o a password
  $mysqldump --opt webwork         dumps the DB to the screen
Now I wrote the wwmysqldump file exactly like this:
  #!/bin/bash
  HOME=~/downloads               (note: this folder exists!)
  mysqldump --opt webwork
Then, I chmod it to 744 (xrw-r--r--)
then, when I try to execute it like this 
  $wwmysqldump 
I get 
  error 1045 Access denied for user 'wwadmin'@'localhost' using password: NO
but that is wrong because the .my.cnf file should set the user to 'webworkWrite', right?... 
this is way above my paygrade :) Please HELP !


In reply to Ever Barbero

Re: cannot backup database with wwmysqldump

by Balagopal Pillai -
Shouldn't the line  [client] in .my.cnf be [mysqldump] ?
In reply to Balagopal Pillai

Re: cannot backup database with wwmysqldump

by Ever Barbero -
I added 
  [mysqldump] 
  user="user"
  password="password"
to .my.cnf 
but I still have a problem that (I am sorry) I failed to describe earlier. 
After $sudo chmod 744 wwmysqldump
when I try to run 
  $wwmysqldump
I get "access denied"
so when I wrote my original post I was running it as 
  $sudo wwmysqldump
even though it is located in ~/bin, which is in my home folder!?
I appreciate your help. 

In reply to Ever Barbero

Re: cannot backup database with wwmysqldump

by Balagopal Pillai -
Please try to enable execute permissions for a regular user like this -
chmod 755  wwmysqldump  
In reply to Ever Barbero

Re: cannot backup database with wwmysqldump

by Danny Glin -
The HOME variable should be set to the home directory of the user who is running the command, not the directory where you want the backups to be saved. This is where the script looks for configuration files (in this case, .my.cnf in particular). Also, it's a bad idea to use ~ for paths if you plan to run the script using cron, since this isn't necessarily set when cron is run.

For your version of the wwmysqldump script, you should change the second line to
HOME=/home/wwadmin
(assuming that that is the correct home directory for wwadmin), then it should be able to dump the database without a password. The way you have it now, it will dump it to the screen. Once you have this working you can change the third line to
mysqldump --opt webwork > /home/wwadmin/downloads
(assuming /home/wwadmin/backups is where you want the backups to go).