473,769 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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'@'loc alhost' 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 1745
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*******@attgl obal.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*******@attgl obal.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
15464
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 shows all current backups, and restores the selected one with one click...
4
12726
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 though the file may be too big! When I try to do it via command line: mysql -u root --host=localhost printing < ./printing.txt It eventually errors out with a "syntax error on line X" and only about
10
8984
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 the name mysql might have made a database file under? Where is it stored? Just curious. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mlh@appserver mlh $ mysql / -u root -p
3
5771
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 drive onto a USB External Hard Drive. I have to assume I also copied the data. I
4
4898
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 experience from people that are already running similar dimensioned database/application. As a rought estimate the database has around 80 tables 4-5 of these are supposed to grow up to 5.000.000 records another 30% will be in the 100.000 range...
110
10628
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 case scenario for MyISAM backend? Also is it possible to not to lose data but get them corrupted?
3
3641
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, hosted by a hosting company. Last week, all tables in MySQL suddenly disappeared and a "func" table is created there. I never create that table in my database. I asked the Hosting company what happened. The staff claimed that most probably my...
5
6567
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. The SAS users are laughing because they can (to a certain extend) easily go back to an earlier SAS table by simply starting dsm. Of course, a flat file table is different than a relational table; but still, the trouble related to restoring DB2...
0
12901
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 database system developed specifically for large enterprise databases. All advanced features of a relational database are fully implemented. - Once you purchase the product, you are only limited to the Sybase-derived engine.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.