Configure a backup schedule in the Jenkins pipeline

Configure a backup schedule in the Jenkins pipeline

This section describes how to configure the MySQL backup schedule in the Galera database backup Jenkins pipeline.

To configure the backup schedule for a MySQL database:

  1. Verify that you have enabled the schedule as described in Enable a backup schedule for a MySQL database.

  2. Verify that cron for the innobackupex-runner script is disabled:

    1. Log in to the Salt Master node.

    2. Verify that the value of the cron parameter is defined in the pillar data. The parameter should be set to false.

      salt -C 'I@xtrabackup:client' pillar.data xtrabackup:client:cron
      salt -C 'I@xtrabackup:server' pillar.data xtrabackup:server:cron
      

      If the parameter is not defined or set to true, manually change the value to false in the infra/backup/client_mysql.yml on the cluster Reclass level.

    3. If the schedule was configured before, remove the old schedule configuration by removing the backup_times pillar block from the cluster/infra/config/init.yml and cluster/openstack/database/init.yml files if it is present in parameters:xtrabackup:client.

    4. Apply the xtrabackup state:

      salt -C 'I@xtrabackup:client or I@xtrabackup:server' state.sls xtrabackup
      
    5. On the dbs01 node, verify that crontab is working and the Xtrabackup job is disabled:

      crontab -l
      # Lines below here are managed by Salt, do not edit
      # SALT_CRON_IDENTIFIER:/usr/local/bin/innobackupex-runner.sh
      # DISABLED 0 */12 * * * /usr/local/bin/innobackupex-runner.sh
      
    6. Verify the system response of the following command:

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

      The system response should include the following parameters for the Jenkins trigger but the values may vary:

      parameters:
        _param:
          backup_min: "0"
          backup_hour: "*/12"
          backup_day_of_month: "*"
          backup_month: "*"
          backup_day_of_week: "*"
      

      If the above parameters are not defined, set them up in infra/init.yml on the cluster Reclass level.

  3. Configure the Galera database backup pipeline as required:

    1. Open the cluster Reclass level of your deployment.

    2. Move the include of the infra.backup.client_mysql level from openstack/database/master.yml to openstack/database/init.yml.

    3. Refresh the grains to be able to get correct IP addresses for /.ssh/authorized_keys.

      salt -C I@xtrabackup:client state.sls salt
      salt -C I@xtrabackup:client mine.update
      salt -C I@xtrabackup:client saltutil.sync_all
      
    4. Apply the xtrabackup state to configure access for new nodes:

      salt -C I@xtrabackup:server state.sls xtrabackup
      
    5. In cicd/control/leader.yml, add the following class:

      classes:
      - system.jenkins.client.job.deploy.galera_database_backup
      
    6. Re-apply the jenkins state on the cid01 node:

      salt -C I@jenkins:client state.sls jenkins
      
    7. Optional. To define a custom backup time, override the backup paramateters in the infra/init.yml file:

      parameters:
        _param:
          backup_min: "0"
          backup_hour: "*/12"
          backup_day_of_month: "*"
          backup_month: "*"
          backup_day_of_week: "*"
      
      Backup parameters details

      Parameter name

      Description

      Possible values

      backup_min

      Value in minutes when the backup should run

      0-59, *

      backup_hour

      Value in hours when the backup should run

      0-23, *

      backup_day_of_month

      Value in days of month when the backup should run

      1-31, *

      backup_month

      Value in months when the backup should run

      0-23, *

      backup_day_of_week

      Value in days of week when the backup should run

      0-6, *

      All parameters can also use / to mark the iteration. For example, the */12 value for the backup_hour parameter means that the backup will start every twelfth hour. See Jenkins cron syntax in the official Jenkins documentation for the details.