当以--log-update=file_name选项启动时,mysqld将所有更新数据的SQL命令写入记录文件中,如果对改日志文件进行操作是否可实现增量备份的功能?

解决方案 »

  1.   

    可以用--log-update实现增量备份,但最好还是全备份得好。
      

  2.   

    If you use the --log or -l options, mysqld writes a general log with a  lename of
    `hostname.log', and restarts and refreshes do not cause a new log  le to be generated
    (although it is closed and reopened). In this case you can copy it (on Unix) by doing:
    mv hostname.log hostname-old.log
    mysqladmin flush-logs
    cp hostname-old.log to-backup-directory
    rm hostname-old.log
    Update logging is smart because it logs only statements that really update data. So an
    UPDATE or a DELETE with a WHERE that  nds no rows is not written to the log. It even skips
    UPDATE statements that set a column to the value it already has.
    The update logging is done immediately after a query completes but before any locks are
    released or any commit is done. This ensures that the log will be logged in the execution
    order.
    If you want to update a database from update log  les, you could do the following (assuming
    your update logs have names of the form `file_name.###'):
    shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
    ls is used to get all the log  les in the right order.
    This can be useful if you have to revert to backup  les after a crash and you want to redo
    the updates that occurred between the time of the backup and the crash.