mysqlbinlog — Utility for Processing Binary Log Files loss occurs. The example assumes that the server is running on host  host_name  and its first binary log file is named  binlog.000999 . Enter each command on a single line. Use  mysqlbinlog  to make a continuous backup of the binary log: mysqlbinlog --read-from-remote-server --host= host_name  --raw --stop-never binlog.000999 Use  mysqldump  to create a dump file as a snapshot of the server’s data. Use  --all-databases ,  -- events , and  --routines  to back up all data, and  --master-data=2  to include the current binary log coordinates in the dump file. mysqldump --host= host_name  --all-databases --events --routines --master-data=2>  dump_file Execute the  mysqldump  command periodically to create newer snapshots as desired. If data loss occurs (for example, if the server unexpectedly exits), use the most recent dump file to restore the data: mysql --host= host_name  -u root -p <  dump_file Then use the binary log backup to re-execute events that were written after the coordinates listed in the dump file. Suppose that the coordinates in the file look like this: -- CHANGE MASTER TO MASTER_LOG_FILE=’binlog.001002’, MASTER_LOG_POS=27284; If the most recent backed-up log file is named  binlog.001004 , re-execute the log events like this: mysqlbinlog --start-position=27284 binlog.001002 binlog.001003 binlog.001004 | mysql --host= host_name  -u root -p You might find it easier to copy the backup files (dump file and binary log files) to the server host to make it easier to perform the restore operation, or if MySQL does not allow remote  root  access. Binary log backups with  mysqlbinlog  are subject to these restrictions: • mysqlbinlog  does not automatically reconnect to the MySQL server if the connection is lost (for example, if a server restart occurs or there is a network outage). •The delay for a backup is similar to the delay for a replica server. mysqlbinlog Backup Restrictions 4.6.9.4 Specifying the mysqlbinlog Server ID When invoked with the  --read-from-remote-server  option,  mysqlbinlog  connects to a MySQL server, specifies a server ID to identify itself, and requests binary log files from the server. You can use mysqlbinlog  to request log files from a server in several ways: •Specify an explicitly named set of files: For each file,  mysqlbinlog  connects and issues a  Binlog dump  command. The server sends the file and disconnects. There is one connection per file. •Specify the beginning file and  --to-last-log :  mysqlbinlog  connects and issues a  Binlog dump command for all files. The server sends all files and disconnects. •Specify the beginning file and  --stop-never  (which implies  --to-last-log ):  mysqlbinlog connects and issues a  Binlog dump  command for all files. The server sends all files, but does not disconnect after sending the last one. 624