|
| 1 | +# [borgmatic](https://github.com/borgmatic-collective/borgmatic) |
| 2 | + |
| 3 | +Simple, configuration-driven backup software for servers and workstations. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +> [!NOTE] |
| 8 | +> You may refer to [Orked](https://github.com/irfanhakim-as/orked) for help with setting up a Kubernetes cluster that meets all the following prerequisites. |
| 9 | +
|
| 10 | +- Kubernetes 1.19+ |
| 11 | +- Helm 3.2.0+ |
| 12 | +- Longhorn 1.4.1+ |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Preflight checklist |
| 17 | + |
| 18 | +> [!IMPORTANT] |
| 19 | +> The following items are required to be set up prior to installing this chart. |
| 20 | +
|
| 21 | +### Set up SSH key |
| 22 | + |
| 23 | +An SSH key pair is required for authenticating with the remote Borg server. The public key must be authorised on the remote server, and the private key content should be provided as the value of `borgmatic.global.sshPrivateKey` (shared across all jobs) or `borgmatic.configs.<name>.sshPrivateKey` (per job) in your values file. |
| 24 | + |
| 25 | +1. Generate an SSH key pair: |
| 26 | + |
| 27 | + ```sh |
| 28 | + ssh-keygen -t ed25519 -C "borgmatic" -f ./borgmatic_ed25519 |
| 29 | + ``` |
| 30 | + |
| 31 | +2. Authorise the public key on the remote Borg server: |
| 32 | + |
| 33 | + ```sh |
| 34 | + ssh-copy-id -i ./borgmatic_ed25519.pub <user>@<backuphost> |
| 35 | + ``` |
| 36 | + |
| 37 | + Replace `<user>` and `<backuphost>` accordingly. |
| 38 | + |
| 39 | +3. Copy the private key content for use as the value of `borgmatic.global.sshPrivateKey` or `borgmatic.configs.<name>.sshPrivateKey` in your values file: |
| 40 | + |
| 41 | + ```sh |
| 42 | + cat ./borgmatic_ed25519 |
| 43 | + ``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Recommended configurations |
| 48 | + |
| 49 | +> [!NOTE] |
| 50 | +> The following configuration recommendations might not be the default settings for this chart but are **highly recommended**. Please carefully consider them before configuring your installation. |
| 51 | + |
| 52 | +**This section does not apply to this chart.** |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Application configurations |
| 57 | + |
| 58 | +> [!NOTE] |
| 59 | +> The following configurations are expected or recommended to be set up from within the application after completing the installation. |
| 60 | + |
| 61 | +### Initialise the Borg repository |
| 62 | + |
| 63 | +Each Borg repository must be initialised once before borgmatic can perform backups. |
| 64 | + |
| 65 | +1. Create a one-off shell job for the borgmatic config: |
| 66 | + |
| 67 | + ```sh |
| 68 | + kubectl create job --namespace ${namespace} borgmatic-shell --from=cronjob/${releaseName}-borgmatic-<name>-shell |
| 69 | + ``` |
| 70 | + |
| 71 | + Replace `${namespace}`, `${releaseName}`, and `<name>` with the config name (e.g. `databases`, `files`) accordingly. |
| 72 | + |
| 73 | +2. Once the pod is running, get the pod name and exec into it to initialise the repository: |
| 74 | + |
| 75 | + ```sh |
| 76 | + kubectl get pod --namespace ${namespace} -l job-name=borgmatic-shell |
| 77 | + kubectl exec --namespace ${namespace} -it <pod-name> -- \ |
| 78 | + borgmatic init --encryption repokey-blake2 --config /etc/borgmatic.d/<name>.yaml |
| 79 | + ``` |
| 80 | + |
| 81 | + Replace `${namespace}`, `<pod-name>`, and `<name>` accordingly. |
| 82 | + |
| 83 | +3. Delete the job once initialisation is complete: |
| 84 | + |
| 85 | + ```sh |
| 86 | + kubectl delete job --namespace ${namespace} borgmatic-shell |
| 87 | + ``` |
| 88 | + |
| 89 | + Replace `${namespace}` accordingly. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## How to add the chart repo |
| 94 | + |
| 95 | +1. Add the repo to your local helm client: |
| 96 | + |
| 97 | + ```sh |
| 98 | + helm repo add mika https://irfanhakim-as.github.io/charts |
| 99 | + ``` |
| 100 | + |
| 101 | +2. Update the repo to retrieve the latest versions of the packages: |
| 102 | + |
| 103 | + ```sh |
| 104 | + helm repo update |
| 105 | + ``` |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## How to install or upgrade a chart release |
| 110 | + |
| 111 | +1. Get the values file of the borgmatic chart or an existing installation (release). |
| 112 | + |
| 113 | + Get the latest borgmatic chart values file for a new installation: |
| 114 | + |
| 115 | + ```sh |
| 116 | + helm show values mika/borgmatic > values.yaml |
| 117 | + ``` |
| 118 | + |
| 119 | + **Alternatively**, get the values file of an existing borgmatic release: |
| 120 | + |
| 121 | + ```sh |
| 122 | + helm get values ${releaseName} --namespace ${namespace} > values.yaml |
| 123 | + ``` |
| 124 | + |
| 125 | + Replace `${releaseName}` and `${namespace}` accordingly. |
| 126 | + |
| 127 | +2. Edit your borgmatic values file with the intended configurations: |
| 128 | + |
| 129 | + ```sh |
| 130 | + nano values.yaml |
| 131 | + ``` |
| 132 | + |
| 133 | + Pay extra attention to the descriptions and sample values provided in the chart values file. |
| 134 | + |
| 135 | +3. Install a new release for borgmatic or upgrade an existing borgmatic release: |
| 136 | + |
| 137 | + ```sh |
| 138 | + helm upgrade --install ${releaseName} mika/borgmatic --namespace ${namespace} --create-namespace --values values.yaml --wait |
| 139 | + ``` |
| 140 | + |
| 141 | + Replace `${releaseName}` and `${namespace}` accordingly. |
| 142 | + |
| 143 | +4. Verify that your borgmatic release has been installed: |
| 144 | + |
| 145 | + ```sh |
| 146 | + helm ls --namespace ${namespace} | grep "${releaseName}" |
| 147 | + ``` |
| 148 | + |
| 149 | + Replace `${namespace}` and `${releaseName}` accordingly. This should return the release information if the release has been installed. |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## How to uninstall a chart release |
| 154 | + |
| 155 | +> [!CAUTION] |
| 156 | +> Uninstalling a release will irreversibly delete all the resources associated with the release, including any persistent data. |
| 157 | + |
| 158 | +1. Uninstall the desired release: |
| 159 | + |
| 160 | + ```sh |
| 161 | + helm uninstall ${releaseName} --namespace ${namespace} --wait |
| 162 | + ``` |
| 163 | + |
| 164 | + Replace `${releaseName}` and `${namespace}` accordingly. |
| 165 | + |
| 166 | +2. Verify that the release has been uninstalled: |
| 167 | + |
| 168 | + ```sh |
| 169 | + helm ls --namespace ${namespace} | grep "${releaseName}" |
| 170 | + ``` |
| 171 | + |
| 172 | + Replace `${namespace}` and `${releaseName}` accordingly. This should return nothing if the release has been uninstalled. |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Chart configurations |
| 177 | + |
| 178 | +| Key | Type | Default | Description | |
| 179 | +|-----|------|---------|-------------| |
| 180 | +| borgmatic.configs | object | `{}` | A map of borgmatic configuration jobs, each generating a dedicated CronJob with its own schedule. Items: `.schedule`, `.passphrase`, `.sshPrivateKey`, `.secrets`, `.volumes`, `.content`. | |
| 181 | +| borgmatic.global.passphrase | string | `""` | The passphrase used to encrypt and decrypt the Borg repository, shared across all borgmatic jobs. | |
| 182 | +| borgmatic.global.secrets | object | `{}` | Secret environment variables shared across all borgmatic jobs. | |
| 183 | +| borgmatic.global.sshPrivateKey | string | `""` | SSH private key content shared across all borgmatic jobs. | |
| 184 | +| borgmatic.timezone | string | `""` | The timezone used for the borgmatic CronJob schedule and log timestamps. Default: `"UTC"`. | |
| 185 | +| image.borgmatic.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the borgmatic container image. Default: `"IfNotPresent"`. | |
| 186 | +| image.borgmatic.registry | string | `""` | The registry where the borgmatic container image is hosted. Default: `"ghcr.io"`. | |
| 187 | +| image.borgmatic.repository | string | `""` | The name of the repository that contains the borgmatic container image used. Default: `"borgmatic-collective/borgmatic"`. | |
| 188 | +| image.borgmatic.tag | string | `""` | The tag that specifies the version of the borgmatic container image used. Default: `Chart appVersion`. | |
| 189 | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | |
| 190 | +| resources.borgmatic | object | `{}` | borgmatic container resources. | |
| 191 | +| storage.data.accessMode | string | `""` | The access mode defining how the data storage can be mounted. Default: `"ReadWriteMany"`. | |
| 192 | +| storage.data.enabled | bool | `false` | Specifies whether persistent storage should be provisioned for data storage. | |
| 193 | +| storage.data.storage | string | `""` | The default amount of persistent storage allocated for the data storage. Default: `"1Gi"`. | |
| 194 | +| storage.data.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the data storage. Default: `"longhorn"`. | |
0 commit comments