Unload data from postgres to s3

Question:

I’m trying to unload a table data from postgres database into amazon s3.

I’m aware that redshift has a option of unload into s3 – Since redshift is a postgres database, I tried using the same command in my postgres database but was unsuccesful.

Can someone help me with unloading table data from postgres into s3 periodically ?

Answer:

Redshift is based on a PostgreSQL clone but there’s not 1-1 feature correspondence. If you want to load data from a PostgreSQL DB to Redshift, through S3, you should:

  1. Unload your data from PostgreSQL to a CSV file. To do that use the copy command of psql. See also this Question here.
  2. Copy the CSV file on S3. There are different ways to do that but check the documentation here
  3. Use the COPY command to load the data from S3 to Redshift

Leave a Reply