# Automated backup configuration

### Automated backup configuration

If backup server is in your environment inventory file then add following section to `environments/<environment>/dependencies/values.yaml` and run "Deploy dependencies" workflow:

* Update `backup_server_dir` value to match with your environment name, e/g `development`
* Update `schedule` to reflect best time backup job to be started,
* Set `enabled` to `true`

```
# Backup configuration
backup:
  enabled: true
  schedule: "0 1 * * *"
  backup_server_dir: /home/backup/<environment>
```

Push your changes to GitHub and Re-[Deploy Dependencies](broken://pages/ludL25iSv5QmOBkwXe2D)

If backup server was provisioned as part of any other environments or is a third-party server, then please follow guide from helm chart, see [Backup configuration](https://github.com/opencrvs/infrastructure/blob/develop/charts/dependencies/README.md#backup-configuration).

### Verify backup configuration

**Verify kubernetes jobs are present:**

1. Connect to your cluster with `kubectl`
2. Run following command:

   ```
   kubectl get cronjob -l job-type=backup -n opencrvs-deps-<environment>
   ```

   Example output:

   ```
   NAME              SCHEDULE    TIMEZONE   SUSPEND   ACTIVE   LAST SCHEDULE   AGE
   influxdb-backup   0 1 * * *   <none>     False     0        5h9m            20h
   minio-backup      0 1 * * *   <none>     False     0        5h9m            13h
   mongodb-backup    0 1 * * *   <none>     False     0        5h9m            20h
   postgres-backup   0 1 * * *   <none>     False     0        5h9m            20h
   ```

**Verify Kubernetes jobs were executed per schedule:**

Wait at least for first job execution, usually takes at to 24 hours

1. Connect to your cluster with `kubectl`
2. Run following command:

   ```
   kubectl get job -l job-type=backup -n opencrvs-deps-<environment>
   ```

   Example output:

   ```
   NAME                       STATUS     COMPLETIONS   DURATION   AGE
   influxdb-backup-29381820   Complete   1/1           9s         5h11m
   minio-backup-29381820      Complete   1/1           9s         5h11m
   mongodb-backup-29381820    Complete   1/1           31s        5h11m
   postgres-backup-29381820   Complete   1/1           13s        5h11m
   ```

Verify backup files are present on backup server

1. SSH (Login) to backup server
2. Become backup user:

   ```
   sudo -i
   su - backup
   ```
3. Check backup directory content:

   ```
   ls -l /home/backup/<environment>
   ls -l /home/backup/<environment>/<date>
   ```

   Example output:

   ```
   backup@tmp-backup:~$ ls -l /home/backup/production/2025-11-12
   total 25972
   -rw-r--r-- 1 backup backup    74704 Nov 12 01:00 influxdb_backup_2025-11-12.tar.gz.enc
   -rw-r--r-- 1 backup backup 26506864 Nov 12 01:00 minio_backup_2025-11-12.tar.gz.enc
   -rw-r--r-- 1 backup backup      464 Nov 12 01:00 mongo_backup_2025-11-12.tar.gz.enc
   -rw-r--r-- 1 backup backup      448 Nov 12 01:00 postgres_backup_2025-11-12.tar.gz.enc
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.opencrvs.org/v2.0/technical/guides/installation/opencrvs-maintenance-tasks/backup-and-restore/automated-backup-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
