How to use history option when xtrabackup database?

I need to store the information after xtrabackup database, such as when the backup starts and when is the end time, the backup type,lsn etc.
And after some searching, find there one option history for xtrabackup command. I tested several times, it can run the xtrabackup successfully, but there is no data in table percona_schema.xtrabackup_history.
ps: the version is mysql 8.0.23 + xtrabackup 8.0.23
so what is the right command to run xtrabackup with history option? below is the command I ran:

xtrabackup --user=root -p --backup --target-dir=backup2/ --history

2 Likes

You are correct, all you need to do is to pass --history on xtrabackup command.
You will need to have enough privileges to create a database and a table on the server - PERCONA_SCHEMA.xtrabackup_history .

Here is a sample of the information xtrabackup will save when using --history:

mysql> SELECT * FROM PERCONA_SCHEMA.xtrabackup_history\G
*************************** 1. row ***************************
            uuid: 5df7eded-0b18-11ec-b379-d45d64347a19
            name: NULL
       tool_name: xtrabackup
    tool_command: --backup --stream=xbstream --host=127.1 --port=3310 --history
    tool_version: 8.0.26-18
ibbackup_version: 8.0.26-18
  server_version: 8.0.25-15-debug
      start_time: 2021-09-01 08:32:57
        end_time: 2021-09-01 08:33:02
       lock_time: 1
      binlog_pos: filename 'binlog.001208', position '276', GTID of the last change '31a0afa2-0991-11ec-b94d-d45d64347a19:1-4090912,446df73a-09c1-11ec-9d9d-d45d64347a19:1-7,946bbbde-09c1-11ec-bb72-d45d64347a19:1-227499'
 innodb_from_lsn: 0
   innodb_to_lsn: 5236283927
         partial: N
     incremental: N
          format: xbstream
         compact: N
      compressed: N
       encrypted: N
1 row in set (0,00 sec)

Optionally, you can pass a name to your history entry as --history=my_backup_name and this will reflect in the name field of your entry in PERCONA_SCHEMA.xtrabackup_history table.

1 Like