MYSQL table backups



Hi everyone,

I am having a little bit of trouble backing up some mySQL tables. I've
been trying to adapt a script I found on the internet at
http://blogs.linux.ie/xeer/2005/06/28/simple-mysql-backup/ . However, i
have been having trouble (under bash) on getting it to work.

I know my mysql account has full privileges to all account information.
Using the script below, it even prints out all the table names,
however, when I run this script through the terminal, I get an odd
error saying "mysqldump: error 1044: access denied for user
'USERNAME'@'localhost' to databse '?add-drop-table' when selecting the
database"

It shouldn't be a privileges problem, and because it loops through
every database, I know the script can see every table, but it cannot
dump out the contents of each.

Anyone have a suggestion or alternative?

Thanks much!
Frank

# MYSQL Backup Script
# Contains portions of code from
http://blogs.linux.ie/xeer/2005/06/28/simple-mysql-backup/

export d=$(date +'%Y-%m-%d')
export savepath='/home/idyllico/archive/mysql'
export usr='USERNAME'
export pwd="PASSWORD"

echo "mySQL Backup Script"

mkdir -p $savepath/$d

echo "Dumping entire database.."
mysqldump -add-drop-table -allow-keywords -all-databases -u$usr
-p$pwd > $savepath/$d/all.sql

echo "Dumping individual tables..."

for a in `echo "show databases" | mysql -u$usr -p$pwd | grep -v
Database`;
do
mkdir -p $savepath/$d/$a
echo "Dumping database: $a"
for i in `echo "show tables" | mysql -u$usr -p$pwd $a| grep -v
Tables_in_`;
do
echo " * Dumping table: $i"
mysqldump -add-drop-table -allow-keywords -q -a -c -u$usr -p$pwd $a
$i > $savepath/$d/$a/$i.sql
done
done

echo "Archiving Files..."
tar -C$savepath -c -f$savepath/$d.tar $d
gzip $savepath/$d.tar
echo "Deleting Temp Files"
rm -rf $savepath/$d
echo "Complete"

.



Relevant Pages

  • Re: [Full-disclosure] reduction of brute force login attempts via SSHthrough iptables --
    ... Anyhow its no problem at all to modify, so if you dont like it, just dont use it. ... on a lame script like this as long as it WORKS and is not insecure. ... echo "~ sorting out ip by ip" ... # echo "not enough failed logins, probably no attack from: ...
    (Full-Disclosure)
  • Ripping Tapes with Linux--How To
    ... the full script is located in the BASH ... My tape player is a portable style journalist's recorder from the ... The most irritating part of the recording process was setting the ... echo Starting de-noise procedure to file $TMP1 ...
    (comp.os.linux.misc)
  • Re: How to start mysql at boot time?
    ... I can only assume the values are read into memory during the boot ... > the script to start the mysql server and passing the user mysqld to the ... > script so that the script will run as that user. ... The echo just prints " mysqld" to the console during bootup. ...
    (comp.unix.bsd.openbsd.misc)
  • Re: Linux Backup with Modification Date Filter?
    ... I wrote a bash script that acts as a wrapper to rsnapshot which first ... generates a modification-date filter, ...
    (comp.os.linux.misc)
  • Re: Command Script variable value lost during execution
    ... The value of RC_ver is numeric but ECHO would return it numeric or not... ... I checked ERRORLEVEL at the end of the script and it was 0 but again ... ECHO RoboCopy version xxx%RC_Ver%yyy ... CALL:GetRCVer RoboCopy.exe /Path ...
    (microsoft.public.windows.server.scripting)