Version 3.12.0

2.3.3. Kubernetes/OpenShift

To configure nxs-backup for running in Kubernetes/OpenShift, you need to prepare nxs-universal-chart to run nxs-backup as cron-job, with correct volume mounts and backup job configs.

Here are the steps:

1. Use provided values.yaml from our repo to prepare the cron-job to run nxs-backup by schedule.

2. Prepare correct volume mounts for cron-job. The directory in which the copies will be stored should be mounted as a volume. When backing up files, mount the files to be backed up as volumes (including if required a physical copy of the databases).

3. Prepare the nxs-backup config with backup jobs as configmap, used by cron-job. For more details on how to configure different types of backup jobs, see Usage

Example of nxs-universal-chart values file:

secretEnvs:
  DB_HOST: "mysql"
  DB_USER: "backup"
  DB_PASS: "b@ckupUserPa$s"
  DB_PORT: "3307"

defaultImage: nixyslab/nxs-backup
defaultImageTag: alpine

configMaps:
  config:
    data:
      nxs-backup.conf: |-
        project_name: "My Project"
        server_name: backup-in-k8s
        notifications:
          mail:
            enabled: false

        jobs:
        - job_name: backup-mysql
          type: mysql
          tmp_dir: /var/nxs-backup/dump_tmp
          sources:
          - name: mysql
            connect:
              db_host: ENV:DB_HOST
              db_port: ENV:DB_PORT
              db_user: ENV:DB_USER
              db_password: ENV:DB_PASS
            target_dbs:
            - project-db
            gzip: true
            db_extra_keys: '--opt --add-drop-database --routines --comments --create-options --quote-names --order-by-primary --hex-blob --single-transaction'
    storages_options:
        - storage_name: local
          backup_path: /var/nxs-backup/databases
          retention:
            days: 7
            weeks: 3
            months: 1

cronJobs:
  nxs-backup-database-hourly:
    schedule: "0 2 * * *"
    containers:
    - name: nxs-backup
      envSecrets:
      - secret-envs
      volumeMounts:
      - name: config
        mountPath: /etc/nxs-backup
      - name: nxs-backup
        mountPath: /var/nxs-backup
    volumes:
    - type: configMap
      name: config
    - name: nxs-backup
      type: pvc

pvcs:
  nxs-backup:
    size: 200Gi