LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   /var/lib/mysql contents - What to backup (https://www.linuxquestions.org/questions/linux-general-1/var-lib-mysql-contents-what-to-backup-327146/)

chakkerz 05-25-2005 09:32 PM

/var/lib/mysql contents - What to backup
 
Hi there

I am trying to transfer an entire server to a new server and do a whole heap of house keeping while i'm at it. On of the things that has come up early is the databases the old server is hosting. Every subdirectory in /var/lib/mysql is a database as I understand it, so I'm confident that those need to be backed up. I haven't had a close look at the directories but i'm not too phased by that aspect. What has me a little surprised are the main-bin.001 to main-bin.xxx files as well as the main-relay-bin.001 to whatever files.

Anyone know what the purpose of those files (/var/lib/mysql/main-bin.xxx and main-relay-bin.xxx) is, what they do and the like.

(I have googled and found nothing relevant). Any input would be appreachiated.

trickykid 05-25-2005 09:55 PM

Don't backup just those directories.. do it the correct way and do it with mysqldump command.

chakkerz 05-25-2005 09:59 PM

Good point

chakkerz 05-25-2005 10:25 PM

Now according to the manual (http://dev.mysql.com/doc/mysql/en/mysqldump.html) the following means are available:

dump a database to a remote host:
shell> mysqldump --opt db_name | mysql --host=remote_host -C db_name

It is possible to dump several databases with one command:
shell> mysqldump --databases db_name1 [db_name2 ...] > my_databases.sql

If you want to dump all databases, use the --all-databases option:
shell> mysqldump --all-databases > all_databases.sql

and

You can read the dump file back into the server like this:
shell> mysql db_name < backup-file.sql

...end copy...

but what it doesn't tell me is how to re-import if all databases are dumped. would i just do the following (for arguments sake):
mysqldump --all-databases > all_databases.sql
scp all_databases.sql another.server.com.au:/some/dir/
<log on to another.server.com.au etc>
mysql < all_databases.sql

Or (even better)
mysqldum --opt --all-databases | mysql --host=another.server.com.au -C

Or what do I put in place of the database name - afterall it would be a hole stack of databases...


All times are GMT -5. The time now is 07:47 PM.