LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-14-2003, 12:33 AM   #1
ram_dhupkar
LQ Newbie
 
Registered: Jul 2003
Location: India pune
Posts: 12

Rep: Reputation: 0
mysql backup


Dear all,

Let me know how can i take mysql server backup without stopping it. Also if some scripts are available for same. what are the thing should remember while taking a backup.

thanks


Ramchandra Dhupkar
 
Old 08-14-2003, 02:57 AM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
I think mysql comes with its own backup tool but I forget what it is. Anyway, you could always simply backup the mysql database directory which is probably /var/lib/mysql.
 
Old 08-14-2003, 06:37 AM   #3
jonas_larson
Member
 
Registered: Jul 2003
Location: Stockholm, Sweden
Distribution: RH9
Posts: 37

Rep: Reputation: 15
Hi,

No! you cannot just backup the mysql dir... If you do you will end up with a non working database...


But mysql comes with two ways of doing the backups...

mysqldump -creates a full backup that you pipe into a file

example:

mysqldump -a -B test > backup_of_test.sql
creates a full backup of "test" database and puts it all into a file called "backup_of_test.sql".
To restore the file just do "mysql -p test < backup_of_test.sql"...

The other way is to do a mysqlhotcopy...

If you are new to mysql I suggest you use mysqldump, look at the man page for more extensive information...

Regards

Jonas
 
Old 08-14-2003, 08:36 AM   #4
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
man i love it when threads i don't start apply to me and make my life easier.
 
Old 08-14-2003, 03:47 PM   #5
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Quote:
Originally posted by jonas_larson
No! you cannot just backup the mysql dir... If you do you will end up with a non working database...
I beg to differ. Although using mysqldump is the preferred way to backup a database you can simply copy the .MYI,.MYD, and .FRM files as well. It has worked for me numerous times in the past.
 
Old 08-15-2003, 02:28 AM   #6
jonas_larson
Member
 
Registered: Jul 2003
Location: Stockholm, Sweden
Distribution: RH9
Posts: 37

Rep: Reputation: 15
Quote:
I beg to differ. Although using mysqldump is the preferred way to backup a database you can simply copy the .MYI,.MYD, and .FRM files as well. It has worked for me numerous times in the past.
That is true only if your database in down, otherwise your database will (or can) be corrupt when you do a restore...

But you might be lucky and nothing at all happens whith your database and then it will work, but I wouldn't trust that backup... ;o)

//jonas
 
Old 08-20-2003, 12:53 PM   #7
dehuszar
Member
 
Registered: Aug 2003
Posts: 41

Rep: Reputation: 15
how bout non-mySQL formats?

I've now searched about 25 threads on incremental backups, and there is usually a dead silence when it comes to the topic. Does anyone know of any way to back up directories incrementally, especially Lotus Notes databases?

Thanks in advance,
Sam
 
Old 08-23-2003, 01:29 PM   #8
jonas_larson
Member
 
Registered: Jul 2003
Location: Stockholm, Sweden
Distribution: RH9
Posts: 37

Rep: Reputation: 15
Quote:
Does anyone know of any way to back up directories incrementally, especially Lotus Notes databases?
Notes database files are regular files! (if you are running a new version of Notes...)
So any tool that can do a incremental will do! (tar, cpiol,amanda)

The only thing you need to think about is to shut down notes before the backup to make sure no writes are done while doing the backup...

Regards

Jonas
 
Old 09-06-2003, 05:57 AM   #9
buttersoft
Member
 
Registered: Aug 2003
Distribution: Slackware
Posts: 178

Rep: Reputation: 30
Jonas,

No! you cannot just backup the mysql dir... If you do you will end up with a non working database...

How right you are!

I have linux on a desktop and on a laptop. I thought copy the directory overwrite the laptop directory /var/lib/mysql finish.

No way.
 
Old 09-06-2003, 05:59 AM   #10
buttersoft
Member
 
Registered: Aug 2003
Distribution: Slackware
Posts: 178

Rep: Reputation: 30
mysqldump -a -B test > backup_of_test.sql
creates a full backup of "test" database and puts it all into a file called "backup_of_test.sql".
To restore the file just do "mysql -p test < backup_of_test.sql"...

Could I run on my desktop mysqldump as above copy the sql file to floppy and do the restore on a seperate machine, like a laptop??
 
Old 09-07-2003, 02:57 PM   #11
jonas_larson
Member
 
Registered: Jul 2003
Location: Stockholm, Sweden
Distribution: RH9
Posts: 37

Rep: Reputation: 15
Yes,

That is "the right way" to do it. It will work great, the only thing you might have to adjust is the user. (if you had some other user on your laptop...)

Good luck

Jonas
 
Old 09-07-2003, 03:07 PM   #12
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Recently, we are talking like 2 days ago, I had to restore a database that wasn't working very well. I tried restoring from another backup solution, and only ended up screwing myself bigtime. Eventually, what worked for me was pulling out a full backup of /var and grabbing the files from /var/lib/mysql/DATABASE and copying them over, file by file (the imssing ones that the mysqldump seemed to have problems remembering to grab?) and got the pup restored.

So, it may be the "right way" but in my sad situation, if I had solely followed the "right way" I'd have been screwed. It took a combo of both "the right way" and apparently "the wrong way" to get things restored and in working order.



Cool
 
Old 09-09-2003, 03:10 PM   #13
jonas_larson
Member
 
Registered: Jul 2003
Location: Stockholm, Sweden
Distribution: RH9
Posts: 37

Rep: Reputation: 15
Hi MasterC,

Just to put the record straight...

I never said you couldn't restore from /var/lib/mysql (or where ever you put the files...) if you shut down mysql first...

The discussion was about a "hot" backup, i.e. taking a backup while the database is up. (in use) The problem you might get is that some table is in the progress of updating it's data and in that instance you copy the files -> thus getting a mixture of old and new data...

I say "might" because it is not sure that will happen. You might be able to take a backup that way 99 times of 100. The problem is the 100th time... ;o)

Regards

Jonas
 
Old 09-09-2003, 07:19 PM   #14
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Right on I meant nothing from that other than that you were both correct, especially since it took a combo of both of your ways to get mine back up when it jumped ship I understand and can completely appreciate "the correct" way to do things, and thank you for the information as such

Cool
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Backup MySQL over the network gabriellai Linux - Enterprise 3 07-19-2005 09:42 AM
Mysql backup? marghorp Linux - Software 11 02-24-2004 01:18 PM
MYSQL backup problem wimpie_net Linux - Software 5 10-16-2003 04:03 PM
mysql backup ram_dhupkar Linux - General 0 08-13-2003 03:46 AM
Backup MySQL w/ CRON tracer Linux - General 0 03-28-2003 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration