Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to make a back-up of a database on CentOS 5.5, running MySQL server from the command line. Basically I need to export everything in it.

share|improve this question… May provide interesting reading on this topic. – sysadmin1138 Mar 21 '11 at 13:03
up vote 4 down vote accepted

mysqldump - read the man page for details.

Note that it may take a time to generate the full backup file - if you want a consistent backup then consider setting up a replication slave (and turn off replication while taking the backup).

share|improve this answer

If you have a large database which you want to keep online (i.e. not read lock) during backups you can also consider the innobackupex script which uses xtrabackup from percona which supports online backups of both inno and myisam (to some degree of consistency)

Zmanda has a ZRM manager product which wraps the mysqldump tool and combines a scheduler and reporting agent which is convenient for managing cron jobs and recovery.

xtrabackup manager is also a command line tool that wraps the invocations and manages the scheduling to some degree...

There is also holland, another command line mysql backup wrapper which supports a number of backends.

Following on from @symcbean this is my attempt at taking a consistent command line dump of the system, with a mixed myisam and innodb engine configuration... (this will obvious make your database read only until it has completed, and any INSERT/UPDATE/DELETE queries will be blocked etc)

SET GLOBAL read_only = ON;

#--single-transaction is only useful if all the tables are innodb
SYSTEM mysqldump --lock-all-tables --quick --all-databases > all-databases.sql

SET GLOBAL read_only = OFF;

the caveats are that GLOBAL read_only does not respect root users, so if you run your web apps as root then you would have to make sure they were stopped also.

also if your filesystem is xfs, or on LVM you can use the native fs tools to get a READ lock at the fs level which obviates the requirement for database level locking. for example for xfs;

SYSTEM xfs_freeze

and for lvm there is the dmsetup.

share|improve this answer

Use mylvmbackup to take snapshots of the filesystem or (if the database is small) mysqldump to get a SQL dump. I don't recommend mysqldump for large datasets.

Also, mysqlhotcopy is perfect for MyISAM.

For InnoDB try Hot-Backup, but it costs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.