After a minor coding blitz I have created 3 patches for mysqlbinlog (one is more of an enhancement of a previous patch):
- Compression support (patch here)
- SSL support (patch here)
- RAW mode (updated patch
here) - See update below for updated patch
The compression support patch adds the --compress parameter adds support for compression when retrieving data from a remote MySQL server, much in the same way that other mysql clients do. Basic tests indicate it compresses data up to 10x for SBR statements.
The SSL support patch adds the --ssl* parameters to the mysqlbinlog client just as the other mysql clients.
The RAW mode patch is almost an entire rewrite of the original RAW mode patch fixing all the problem introduced in it. For those not familia with it the patch introduces a way of backing up the remote binlog files without having a remote slave running or using something like SCP. One possible usage for this to have a live up-to-the-second backup of your data like this:
- Run mysqlbinlog --raw --read-from-remote-server --host=mysqlserver.address --to-last-log=2 mysqld-bin.000001
- Grab a mysqldump --master-data=2 --host=mysqlserver.address
- Repeat #2 every hour (or however long you want the snapshots to be)
Change summary:
- mysqlbinlog safe exits with CTRL-C or kill
- --raw added which will retrieve raw binlog files from the remote server and save them using the filenames in the replication headers
- --to-last-log is now an int, =1 is the old behaviour (stop at end of last log), =2 is continuous (sets serverID=255)
- --result-dir added for use with --raw mode
- --result-file modified so that when used with --raw mode it is a prefix for the output files
UPDATE 2009-03-13:
A user of this patch noticed 2 bugs with it. Firstly the --result-dir caused a crash if the directory did not exist, and secondly it was not handling the binlog headers correctly. I have fixed both of these problems and take4 of the patch can be found here.