Binary backup of AWS RDS PostgreSQL - postgresql

I am looking for a way to do a regular binary backup of my AWS RDS PostgreSQL database to use this copy locally and mount it in my docker postgis container. As far as I have understood, I cannot connect to the RDS host and do pg_basebackup.
So what is the best way to do this task?
The best workflow would be: There is an automatic daily binary backup stored in AWS S3. Then locally, some shell script to download the files to a folder that is mounted to the postgis folder.
Any ideas if that is possible?
I have one more additional requirement: I would like to exclude specific tables in the backup.

Related

Restore backups to postgres instance on another server through pgbackrest

I'm trying to backup/restore from one postgres instance on one virtual machine to another postgres on another vm. How to give paths in pg_hba.conf?
[global]
repo1-path=/var/lib/pgsql/12/backups/
log-level-console=info
log-level-file=debug
start-fast=y
repo1-retention-full-type=time
repo1-retention-full=15
[my_stanza]
pg1-path=/var/lib/pgsql/12/data/
Also is it possible to restore on another postgres instance if backups are stored on S3, GCS or Azure? If yes, How?

loading one table from RDS / postgres into Redshift

We have a Redshift cluster that needs one table from one of our RDS / postgres databases. I'm not quite sure the best way to export that data and bring it in, what the exact steps should be.
In piecing together various blogs and articles the consensus appears to be using pg_dump to copy the table to a csv file, then copying it to an S3 bucket, and from there use the Redshift COPY command to bring it in to a new table-- that's my high level understanding, but am not sure what the command line switches should be, or the actual details. Is anyone doing this currently and if so, is what I have above the 'recommended' way to do a one-off import into Redshift?
It appears that you want to:
Export from Amazon RDS PostgreSQL
Import into Amazon Redshift
From Exporting data from an RDS for PostgreSQL DB instance to Amazon S3 - Amazon Relational Database Service:
You can query data from an RDS for PostgreSQL DB instance and export it directly into files stored in an Amazon S3 bucket. To do this, you use the aws_s3 PostgreSQL extension that Amazon RDS provides.
This will save a CSV file into Amazon S3.
You can then use the Amazon Redshift COPY command to load this CSV file into an existing Redshift table.
You will need some way to orchestrate these operations, which would involve running a command against the RDS database, waiting for it to finish, then running a command in the Redshift database. This could be done via a Python script that connects to each database (eg via psycopg2) in turn and runs the command.

Is there any approach to migrate PostgreSQL database from Azure to AWS RDS PostgreSQL

I able to migrate from on-prem database to AWS using DMS service but couldn't able to migrate database from Azure to AWS.
Is there any better approach?
A pretty low level but effective way would be to: export your Azure data as CSV using pg_dump,
copy it into an AWS S3 bucket (pretty easy with Python awscli package) and load from S3 into RDS Postgres.
Would be great if files could be moved directly from blob storage to s3, but I don't think Azure Postgres supports dumping directly to blob anyway.

Get big(250Gb) RDS PostgreSQL db dump into my local machine

My problem is to get big(250Gb) postgres dump on my local machine.
Its on AWS RDS. I tried to dump it to local machine, but it takes too long, kinda 3+ days.
Trying to find a way to dump it into S3 and download from there safely. May be you could suggest more effective way to do that. Will appreciate any kind of help.
Thanks!
As of my knowledge, aws does not provide a way to backup db into s3
you can take a look into this question and answers,
Export huge database from amazon RDS to local mysql
here is one answer
If the data is that big I would suggest copying the RDS snapshot on S3, as explained here.
Link to documentation to copy snapshot to s3
This topic is covered in this StackOverflow thread Exporting a AWS Postgres RDS Table to AWS S3
Another solution would be to spin up an EC2 instance and dump the database to a local EBS volume that is large enough for the following steps. Then chose one of the following:
Compress the DB dump into multiple files and copy to S3 for download. I would use a smart S3 download manager given the size of the database dump.
Export the S3 data using Snowball Export S3 Data. If your Internet connection is not fast enough / reliable enough then Snowball will get you the data.

How to load a backup DB file in AWS RDS Postgresql

I've got a PostgreSQL backup file (tar zipped) and I would like to restore it in fresh Amazon RDS instance. I loaded the backup file in S3 but I don't know how to restore it in Postgresql RDS. Thanks for your help.
Amazon has a very good document for this procedure.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.html