473,383 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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/2...-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/2...-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"

Apr 29 '06 #1
6 1718
This is no PHP.

The -add-drop-table switch for mysqldump is wrong: should be
--add-drop-table. Also check out the other switches.

Apr 30 '06 #2
If you're just doing backups, you can also just tarzip the mysql data dir
and do a quick and dirty backup that way.
May 1 '06 #3
Jimbus wrote:
If you're just doing backups, you can also just tarzip the mysql data dir
and do a quick and dirty backup that way.


That's not safe at all. For instance - if MySQL is upgraded, your backups may
suddenly be unusable.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '06 #4
>> If you're just doing backups, you can also just tarzip the mysql data dir
and do a quick and dirty backup that way.

"dirty" is a good word for it. Unless you make sure that all changes
have been flushed to disk, and that no other changes are made during
making the backup, what you save may not be up to date (or even
consistent). For example, shut down the server (cleanly) first.
That's not safe at all. For instance - if MySQL is upgraded, your backups may
suddenly be unusable.


To the extent that the backups are good at all, you can still restore
those backups on a machine running the old version, then mysqldump,
and restore on the new version. This is, of course, a lot of
trouble compared to doing it right with mysqldump the first time.

Gordon L. Burditt
May 1 '06 #5
Gordon Burditt wrote:
If you're just doing backups, you can also just tarzip the mysql data dir
and do a quick and dirty backup that way.

"dirty" is a good word for it. Unless you make sure that all changes
have been flushed to disk, and that no other changes are made during
making the backup, what you save may not be up to date (or even
consistent). For example, shut down the server (cleanly) first.

That's not safe at all. For instance - if MySQL is upgraded, your backups may
suddenly be unusable.

To the extent that the backups are good at all, you can still restore
those backups on a machine running the old version, then mysqldump,
and restore on the new version. This is, of course, a lot of
trouble compared to doing it right with mysqldump the first time.

Gordon L. Burditt


If you have a machine running the old version, that is.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '06 #6
On Mon, 01 May 2006 17:09:46 +0000, Gordon Burditt wrote:
If you're just doing backups, you can also just tarzip the mysql data
dir and do a quick and dirty backup that way.


"dirty" is a good word for it. Unless you make sure that all changes have
been flushed to disk, and that no other changes are made during making the
backup, what you save may not be up to date (or even consistent). For
example, shut down the server (cleanly) first.


Or use mysqlhotcopy and leave the server running...

http://dev.mysql.com/doc/refman/5.0/...qlhotcopy.html

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

May 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James | last post by:
HI, I'm looking for a script that will allow users/admins to have a one click backup solution for a MYSQL Database.. 'BACK DATABASE' button, click and its done... The a restore option, that...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
10
by: MLH | last post by:
I have a database named credifree. I did it with mysql's create command. Yet, I can find no files on my linux box except for a\ directory and a gif file that have the name credifree. Why? What's...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
4
by: Federico | last post by:
Hi everybody, I'm evaluating the possibility of using MySQL 5.0 as a database backend for an application we are doing and I'd like to have hardware requirements rough estimates and/or real world...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
3
by: wongwaichi | last post by:
Hi, everyone. I am not sure if i am writing in the correct group. But somehow it relates to MySQL, i hope someone can help me. I am working on a web site which is developed by PHP and MySQL,...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
0
Coldfire
by: Coldfire | last post by:
Since i cannot show the differences in a two-column like table. I am first putting MS SQL Server 2005 and then MySQL 5.x. MS SQL Server 2005 Brief Overview - SQL Server is a full-fledged...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.