postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Support redirecting backup files to SFTP server

Open NiharDudam opened this issue 7 years ago • 3 comments

What is the motivation or use case for the feature?

Most of our customers are already scheduling their backups onto a SFTP server. Currently, pgbackrest only supports Amazon S3 storage. We need to support SFTP as a reliable storage mechanism for Postgres backups

Describe the solution you'd like Add support for redirecting backups to an SFTP server

Describe any alternatives you've considered Please help if we have any alternatives to SFTP, thanks

NiharDudam avatar Aug 07 '19 17:08 NiharDudam

1)@NiharDudam you could configure pgbackrest for local backups on your SFTP for that. Current approach with pgbackrest - separate pod with pgbackrest is created for local storing of backups. 2)Or you can configure shared-backrest pod with pg-host + repo-host options to take files from DB and store them to your remote. but it requires ssh trusted connection

lkhomenk avatar Aug 07 '19 18:08 lkhomenk

@lkhomenk During one of our calls with Crunchy it was suggested that we also look at pgdump and pgbasebackup as there may be issues with tarring and untarring pgbackrest files.

I have done some tarring up of pgdump and pgbasebackup files, untarring and then restore and it seems to work ok but from our point of view I would like to understand the limitations with these two methods.

From what I have read pgdump is more suitable for smaller amounts of data. It can take a long time and it does not give us options such as incremental or diff backups. it is just a basic SQL dump of the database. pgbasebackup seems to have some more capabilities such as Point in time recovery but again is missing the extra features that pgbackrest offers such as incremental, diff backups, high backiup/restore throughput, verification of integrity, pause, resume, etc

I have read https://blog.dbi-services.com/pgbackrest-dedicated-backup-host/ and it indicates that the backups will automatically be copied to a ssh server. Is this something that Crunchy supports. Is there separate docs on this I would like to try it out as it looks like a more viable option for us. I can't see options in backup-opts that would fit here - does the /etc/pgbackrest.conf file need to be updated manually - and is this supported?

I have logged onto the backrest backup pod and been able to see the backed up files mounted form the PVC. It was mentioned in the call that it might be problematic to tar and untar these files. I have been able to get this to work but am concerned about what issues might arise. Have you more info on this or have you any recommendations / advice around this?

louiseohalloran avatar Aug 22 '19 12:08 louiseohalloran

In v4.2.0, to facilitate the clone feature, we added a new container called pgo-backrest-repo-sync in order to copy a pgBackRest repository to a new PVC. The way we accomplish this is by using rsync, which you can see here:

https://github.com/CrunchyData/postgres-operator/blob/master/bin/pgo-backrest-repo-sync/pgo-backrest-repo-sync.sh#L94-L96

(There is also code for the S3 sync as well)

The side-effect of this change is that we've added rsync to the pgBackRest repository itself! This means that you can write your own jobs to synchronize your pgBackRest repository via rsync to other sources.

Given rsync can work over ssh (and personally, I do prefer rsync + ssh over SFTP for something like this), you can control how you want your backups to be redirected. You could even leverage a Kubernetes CronJob to write your own script to handle an off-site backup (likely modeled off of the pgo-backrest-repo-sync.sh that is linked to above, and shows how to mount the appropriate Secrets, etc.).

As such, I do not see an immediate needs to support SFTP natively in the PostgreSQL Operator. Given the countably infinite number of ways to handle synchronizing backups across different media outside of what the Operator offers, I am not sure if we want to support "backups of backups" in the Operator (beyond what we have with the local,s3 option)...or at least not at this time.

jkatz avatar Jan 04 '20 20:01 jkatz