Configure a backup schedule using the Xtrabackup script directly

Configure a backup schedule using the Xtrabackup script directlyΒΆ

This section describes how to configure the MySQL backup schedule using the Xtrabackup script based on the crontab record.

Note

We recommend that you Configure a backup schedule in the Jenkins pipeline instead of using the Xtrabackup script directly.

By default, Xtrabackup stores three complete backups with their incremental backups. This section describes how to override the default configuration of the backup schedule for a MySQL database. To enable the backup schedule in your deployment, refer to Enable a backup schedule for a MySQL database.

To configure a backup schedule for a MySQL database:

  1. Log in to the Salt Master node.

  2. Select from the following options:

    • Override the default Xtrabackup configuration by setting a custom time interval in cluster/infra/config/init.yml.

      1. Set the following parameters as required:

        hours_before_full

        Sets the full backup frequency. If set to 48, the full backup is performed every two days. Within 48 hours, only incremental backups are performed.

        full_backups_to_keep

        Sets the number of full backups to keep.

        incr_before_full

        Sets the number of incremental backups to be performed between full backups. If set to 3, three incremental backups will be performed between full backups.

        cron

        If set to false, disables the automatic backup by removing the cron job that triggers an automatic backup. Set cron: true to enable the automatic backup.

        Configuration example:

        parameters:
          xtrabackup:
            server:
              enabled: true
              hours_before_full: 48
              full_backups_to_keep: 5
              incr_before_full: 3
              cron: false
        
      2. Verify that the hours_before_full parameter of the xtrabackup client in cluster/openstack/database/init.yml matches the same parameter of the xtrabackup server in cluster/infra/config/init.yml.

    • Set the exact backup time for the Xtrabackup server role in cluster/infra/config/init.yml and the Xtrabackup client role in cluster/openstack/database/init.yml by configuring the backup_times section.

      The backup_times parameters include:

      day_of_week

      The day of a week to perform backups. Specify 0 for Sunday, 1 for Monday, and so on. If not set, defaults to *.

      day_of_month

      The day of a month to perform backups. For example, 20, 25, and so on. If not set, defaults to *.

      Note

      Only day_of_week or day_of_month can be active at the same time. If both are defined, day_of_week is prioritized.

      month

      The month to perform backups. Available values include 1 for January, 2 for February, and so on up to 12 for December.

      hour

      The hour to perform backups. Uses the 24-hour format. If not defined, defaults to 1.

      minute

      The minute to perform backups. For example, 5, 10, 59, and so on. If not defined, defaults to 00.

      Note

      If any of the individual backup_times parameters is not defined, the default * value will be used. For example, if the minute parameter is *, the backup will run every minute, which is usually not desired.

      Caution

      Only backup_times section or hours_before_full(incr) can be active. If both are defined, the backup_times section will be prioritized.

      Configuration example for the Xtrabackup server role:

      parameters:
        xtrabackup:
          server:
            enabled: true
            full_backups_to_keep: 3
            incr_before_full: 3
            backup_dir: /srv/backup
            backup_times:
              day_of_week: 0
              hour: 4
              minute: 52
            key:
              xtrabackup_pub_key:
                enabled: true
                key: key
      

      Configuration example for the Xtrabackup client role:

      parameters:
        xtrabackup:
          client:
            enabled: true
            full_backups_to_keep: 3
            incr_before_full: 3
            backup_times:
              day_of_week: 0
              hour: 4
              minute: 52
            compression: true
            compression_threads: 2
            database:
              user: username
              password: password
            target:
            host: cfg01
            cron: true
      

      The cron parameter, if set to false, disables the script that automatically triggers the backup scripts. For the correct backup strategy, set up cron to true or use the backup pipeline as described in Configure a backup schedule in the Jenkins pipeline.

  3. Apply changes by performing the steps 5-10 of the Enable a backup schedule for a MySQL database procedure.