If you are able to shut down your MySQL server, you can make a binary backup that consists of all files used by
InnoDB
to manage its tables. Use the following procedure:
Stage 1: Copy binary data
- Shut down the MySQL server and make sure that it stops without errors.
- Copy your
my.cnf
configuration file or files to a safe place.
Stage 2: Dump and restore full database
In addition to making binary backups as just described, you should also regularly make dumps of your tables with mysqldump. The reason for this is that a binary file might be corrupted without you noticing it. Dumped tables are stored into text files that are human-readable, so spotting table corruption becomes easier. Also, because the format is simpler, the chance for serious data corruption is smaller. mysqldump also has a
--single-transaction
option for making a consistent snapshot without locking out other clients.
Stage 3: Restore additional binary logs
To be able to recover your
InnoDB
database to the present from the time at which the binary backup was made, you must run your MySQL server with binary logging turned on. To achieve point-in-time recovery after restoring a backup, you can apply changes from the binary log that occurred after the backup was made - To see a listing of all binary log files, use this statement:
mysql>
SHOW BINARY LOGS;
To determine the name of the current binary log file, issue the following statement:mysql>
SHOW MASTER STATUS;
- The mysqlbinlog utility converts the events in the binary log files from binary format to text so that they can be executed or viewed. mysqlbinlog has options for selecting sections of the binary log based on event times or position of events within the log. See Section 4.6.7, “mysqlbinlog — Utility for Processing Binary Log Files”.
- Executing events from the binary log causes the data modifications they represent to be redone. This enables recovery of data changes for a given span of time. To execute events from the binary log, process mysqlbinlog output using the mysql client:
shell>
mysqlbinlog
binlog_files
| mysql -u root -p
No comments:
Post a Comment