Having a centralized repository (such as Cloud/S3) is crucial for data backup and recovery purposes. It also provides ease when needed to restore the data over different machines/instances. MinIO is one such S3-compatible storage solution that can be deployed anywhere (on-premise, private cloud, etc.), unlike GCP/AWS S3 buckets, which need to be deployed in their respective environments.

In this blog post, we will cover topics like taking backups on MinIO and how we can restore the data over both “local machine” and “k8s/percona postgres operator” based environments. For quick testing in a local setup, MinIO comes in very handy and can be configured with minimal steps.

Let’s discuss this in detail.

Setting up MinIO storage

We are deploying MinIO in a Docker container, which runs over port “9000”. Another port, “9001,” is used for Web console/UI access. 

The Web console is accessed at the address below.

Here, from the UI itself, we have created a bucket named “ajtest”, which we will use to store/retrieve backups. 

pgbackrest MinIO repository

Setting up pgBackRest repository in MinIO

Note: The MinIO user and password (“minioadmin”) will be used as Key/Secrets. Therepo1-s3-region” can be anything, as MinIO is set up locally. 

1) Creating the stanza

Output:

2) Performing pgBackRest health check and connectivity.

Output:

3) Taking the backups.

Output:

The backup will be listed in the minIO web console URL. 

pgBackRest backup in MinIO repos

Also, we can list the backup using the mc-minio tool.

Similarly, we can also set up pgBackRest with MinIO in the K8s/Percona postgres operator environment.

Setting up pgBackRest repository with MinIO in Percona Operator for PostgreSQL

1) MinIO credentials setup.

Output:

2) Creating the secret “cluster1-pgbackrest-secrets.yaml”.

3) Adding the bucket, endpoint, and repo details in the “cr.yaml” file.

4) Inside the pgBackRest repo pod, we can check the status and perform the backup and other related tasks.

So, till here we performed the pgBackRest backup in MinIO under both local and Percona Operator setups. Next, we will perform restoration similarly in  both local and K8s/operator environments.

Restoring pgBackRest in the local environment

1) Stopping the existing database service and cleaning the data directory.

 2)  Restoring the backup.

Output:

3) Starting the database service again.

Note: The required WAL segments for consistent recovery will be fetched from the pgBackRest repository, which is kept in MinIO.

Please also ensure the WAL archiving is in place after restoring the instance.

Restoring pgBackRest in K8s/Percona postgres operator environment

1) Create the restore yaml file and apply it.

2) The restore job ran fine as demonstrated below.

For more details about the restore job, refer to the command below.

3) The postgres pod will be reinitialized with the new restoration and ready to be used.

We can verify the data by simplifying the login inside the respective pod and service.

Note: The restore described above for the PostgreSQL operator will automatically overwrite the existing cluster data. Therefore, we need to be extra cautious, or, if needed, take existing backups before performing any restorations.

Conclusion

MinIO buckets provide an excellent way to test and manage S3-style repositories without having any vendor-specific (AWS/GCP) setup. It supports both traditional and Kubernetes/operator-based environments efficiently. Combined with pgBackRest, PostgreSQL backups/recovery are made quite easy and accessible, almost instant when having a centralized backup repository. 


 


Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments