Enable a backup schedule for a MySQL database

Enable a backup schedule for a MySQL database

To ensure the consistent and timely backing up of your data, create a backup schedule using Xtrabackup.

To create a backup schedule for a MySQL database:

  1. Log in to the Salt Master node.

  2. Verify the configuration of the backup server nodes:

    salt -C 'I@xtrabackup:server' test.ping
    

    If the output of the command above is not empty, move to the next step. Otherwise, configure the xtrabackup server role by adding the following lines in cluster/infra/config/init.yml:

    Note

    By default, Xtrabackup keeps three complete backups and their incrementals on the xtrabackup client node.

    classes:
    - system.xtrabackup.server.single
    parameters:
      _param:
         xtrabackup_public_key: <generate_your_keypair>
    
  3. Sync the pillar data:

    salt '*' saltutil.sync_all
    
  4. Verify the configuration of the backup client nodes:

    salt -C 'I@xtrabackup:client' test.ping
    

    If the output is not empty, move to the next step. Otherwise, configure the xtrabackup client role by adding the following lines in cluster/openstack/database/init.yml:

    classes:
    - system.xtrabackup.client.single
    parameters:
      _param:
        xtrabackup_remote_server: cfg01
        root_private_key: |
          <generate_your_keypair>
    
  5. Verify that the xtrabackup_remote_server parameter is defined correctly:

    salt -C 'I@xtrabackup:client' pillar.get _param:xtrabackup_remote_server
    

    If the system response does not contain an IP address, add the following parameter to cluster/openstack/database/init.yml:

    parameters:
      _param:
        xtrabackup_remote_server: <host_name>
    

    Substitute <host_name> with the resolvable host name of the host on which the Xtrabackup server is running. For example, kvm03, which is the default value in MCP.

  6. Optionally, override the default Xtrabackup configuration as described in Configure a backup schedule for a MySQL database.

  7. Run the following command on the Salt Master node:

    salt '*' saltutil.refresh_pillar
    
  8. Apply the salt.minion state:

    salt -C 'I@xtrabackup:client or I@xtrabackup:server' state.sls salt.minion
    
  9. Refresh grains for the xtrabackup client node:

    salt -C 'I@xtrabackup:client' saltutil.sync_grains
    
  10. Update the mine for the xtrabackup client node:

    salt -C 'I@xtrabackup:client' mine.flush
    salt -C 'I@xtrabackup:client' mine.update
    
  11. Apply the xtrabackup client state:

    salt -C 'I@xtrabackup:client' state.sls openssh.client,xtrabackup
    
  12. Apply the linux.system.cron state:

    salt -C 'I@xtrabackup:server' state.sls linux.system.cron
    
  13. Apply the xtrabackup server state:

    salt -C 'I@xtrabackup:server' state.sls xtrabackup