Now your database contains some data, so it's a good time to learn how to manually make a full backup of your data with the Operator.
!!! note
If you are interested to learn more about backups, their types and retention policy, see the [Backups section](backups.md).
-
In this tutorial we use the AWS S3 :octicons-link-external-16: as the backup storage. You need the following S3-related information:
- The name of S3 bucket;
- The endpoint - the URL to access the bucket
- The region - the location of the bucket
- S3 credentials such as S3 key and secret to access the storage.
If you don't have access to AWS, you can use any S3-compatible storage like MinIO :octicons-link-external-16:. Check the list of supported storages. Find the storage configuration instructions for each
-
The Operator uses the
pgBackRest:octicons-link-external-16: tool to make backups.pgBackReststores the backups and archives WAL segments in repositories. The Operator has up to fourpgBackRestrepositories namedrepo1,repo2,repo3andrepo4. In this tutorial we userepo2for backups. -
Also, we will use some files from the Operator repository for setting up backups. So, clone the percona-postgresql-operator repository:
git clone -b v{{ release }} https://github.com/percona/percona-postgresql-operator cd percona-postgresql-operator!!! note
It is important to specify the right branch with `-b` option while cloning the code on this step. Please be careful.
-
Encode the S3 credentials and the pgBackRest repository name (
repo2in our setup).=== ":simple-linux: Linux"
```bash cat <<EOF | base64 --wrap=0 [global] repo2-s3-key=<YOUR_AWS_S3_KEY> repo2-s3-key-secret=<YOUR_AWS_S3_KEY_SECRET> EOF ```=== ":simple-apple: macOS"
```bash cat <<EOF | base64 [global] repo2-s3-key=<YOUR_AWS_S3_KEY> repo2-s3-key-secret=<YOUR_AWS_S3_KEY_SECRET> EOF ``` -
Create the Secret configuration file and specify the base64-encoded string from the previous step. The following is the example of the
cluster1-pgbackrest-secrets.yamlSecret file:apiVersion: v1 kind: Secret metadata: name: cluster1-pgbackrest-secrets type: Opaque data: s3.conf: <base64-encoded-configuration-contents>
-
Create the Secrets object from this yaml file. Specify your namespace instead of the
<namespace>placeholder:kubectl apply -f cluster1-pgbackrest-secrets.yaml -n <namespace>
-
Update your
deploy/cr.yamlconfiguration. Specify the Secret file you created in thebackups.pgbackrest.configurationsubsection, and put all other S3 related information in thebackups.pgbackrest.repossubsection under the repository name that you intend to use for backups. This name must match the name you used when you encoded S3 credentials on step 1.For example, the S3 storage for the
repo2repository looks as follows:... backups: pgbackrest: ... configuration: - secret: name: cluster1-pgbackrest-secrets ... repos: - name: repo2 s3: bucket: "<YOUR_AWS_S3_BUCKET_NAME>" endpoint: "<YOUR_AWS_S3_ENDPOINT>" region: "<YOUR_AWS_S3_REGION>"
-
Create or update the cluster. Specify your namespace instead of the
<namespace>placeholder:kubectl apply -f deploy/cr.yaml
For manual backups, you need a backup configuration file. {.power-number}
-
Edit the example backup configuration file [deploy/backup.yaml :octicons-link-external-16:] (https://raw.githubusercontent.com/percona/percona-postgresql-operator/v{{ release }}/deploy/backup.yaml). Specify your cluster name and the
reponame.apiVersion: pgv2.percona.com/v2 kind: PerconaPGBackup metadata: name: backup1 spec: pgCluster: cluster2 repoName: repo1 # options: # - --type=full
-
Apply the configuration. This instructs the Operator to start a backup.
kubectl apply -f deploy/backup.yaml -n <namespace>
-
To make a backup takes a while. Track the backup progress:
kubectl get pg-backup -n <namespace>
??? example "Expected output"
``` {.text .no-copy} NAME CLUSTER REPO DESTINATION STATUS TYPE COMPLETED AGE backup1 cluster1 repo2 s3://pg-operator-testing Succeeded full 3m14s 4m46s ```
Congratulations! You have made the first backup manually. Want to learn more about backups? See the Backup and restore section for details like types, retention and how to automatically make backups according to the schedule.
:material-monitor-dashboard: Monitor the database :material-arrow-right:{.md-button}