pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Backup PostgreSQL from RDS straight to S3
5+ messages / 3 participants
[nested] [flat]

* Backup PostgreSQL from RDS straight to S3
@ 2019-09-18 18:32 Anthony DeBarros <adebarros@gmail.com>
  2019-09-18 18:35 ` Re: Backup PostgreSQL from RDS straight to S3 Adrian Klaver <adrian.klaver@aklaver.com>
  2019-09-19 06:03 ` Re: Backup PostgreSQL from RDS straight to S3 Steven Lembark <lembark@wrkhors.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Anthony DeBarros @ 2019-09-18 18:32 UTC (permalink / raw)
  To: pgsql-general

Hi, folks -- I'm a longtime PostgreSQL user but a bit of a noob when it
comes to maintenance. Question:

I'm running PostgreSQL 11 on Amazon RDS. Also have an EC2 box running
Ubuntu that runs some Python scripts that collect data into PostgreSQL.

We're doing the standard RDS backups. However, I'd also like to do a
nightly pg_dump and store that file on S3. Is there a way to go straight
from RDS to S3 without having to download the dump file onto the EC2 box at
any point? I want to avoid a scenario where the DB file fills the EC2 box's
disk.

Thanks for any and all advice!

Anthony

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Backup PostgreSQL from RDS straight to S3
  2019-09-18 18:32 Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
@ 2019-09-18 18:35 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2019-09-18 19:04   ` Re: Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Adrian Klaver @ 2019-09-18 18:35 UTC (permalink / raw)
  To: Anthony DeBarros <adebarros@gmail.com>; pgsql-general

On 9/18/19 11:32 AM, Anthony DeBarros wrote:
> Hi, folks -- I'm a longtime PostgreSQL user but a bit of a noob when it 
> comes to maintenance. Question:
> 
> I'm running PostgreSQL 11 on Amazon RDS. Also have an EC2 box running 
> Ubuntu that runs some Python scripts that collect data into PostgreSQL.
> 
> We're doing the standard RDS backups. However, I'd also like to do a 
> nightly pg_dump and store that file on S3. Is there a way to go straight 
> from RDS to S3 without having to download the dump file onto the EC2 box 
> at any point? I want to avoid a scenario where the DB file fills the EC2 
> box's disk.

?:
https://dba.stackexchange.com/questions/221454/best-way-to-pg-dump-postgresql-on-rds-to-s3

> 
> Thanks for any and all advice!
> 
> Anthony
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Backup PostgreSQL from RDS straight to S3
  2019-09-18 18:32 Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
  2019-09-18 18:35 ` Re: Backup PostgreSQL from RDS straight to S3 Adrian Klaver <adrian.klaver@aklaver.com>
@ 2019-09-18 19:04   ` Anthony DeBarros <adebarros@gmail.com>
  2019-09-18 19:12     ` Re: Backup PostgreSQL from RDS straight to S3 Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Anthony DeBarros @ 2019-09-18 19:04 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general

Great, thanks. The question I have, which at first glance isn't covered
there, is whether those instructions will at any point bring the dump file
onto the EC2 box, either in memory or temp file storage, on its way to S3?
I don't know enough about how Linux handles data piped from one command to
the next to know whether that's standard OP or not.

On Wed, Sep 18, 2019 at 2:36 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 9/18/19 11:32 AM, Anthony DeBarros wrote:
> > Hi, folks -- I'm a longtime PostgreSQL user but a bit of a noob when it
> > comes to maintenance. Question:
> >
> > I'm running PostgreSQL 11 on Amazon RDS. Also have an EC2 box running
> > Ubuntu that runs some Python scripts that collect data into PostgreSQL.
> >
> > We're doing the standard RDS backups. However, I'd also like to do a
> > nightly pg_dump and store that file on S3. Is there a way to go straight
> > from RDS to S3 without having to download the dump file onto the EC2 box
> > at any point? I want to avoid a scenario where the DB file fills the EC2
> > box's disk.
>
> ?:
>
> https://dba.stackexchange.com/questions/221454/best-way-to-pg-dump-postgresql-on-rds-to-s3
>
> >
> > Thanks for any and all advice!
> >
> > Anthony
> >
> >
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Backup PostgreSQL from RDS straight to S3
  2019-09-18 18:32 Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
  2019-09-18 18:35 ` Re: Backup PostgreSQL from RDS straight to S3 Adrian Klaver <adrian.klaver@aklaver.com>
  2019-09-18 19:04   ` Re: Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
@ 2019-09-18 19:12     ` Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Adrian Klaver @ 2019-09-18 19:12 UTC (permalink / raw)
  To: Anthony DeBarros <adebarros@gmail.com>; +Cc: pgsql-general

On 9/18/19 12:04 PM, Anthony DeBarros wrote:
> Great, thanks. The question I have, which at first glance isn't covered 
> there, is whether those instructions will at any point bring the dump 
> file onto the EC2 box, either in memory or temp file storage, on its way 
> to S3? I don't know enough about how Linux handles data piped from one 
> command to the next to know whether that's standard OP or not.

Good intoduction:

https://ryanstutorials.net/linuxtutorial/piping.php

The piping section is down the page

Basically | connects the output of one command directly to input of 
another. Run a test case in one terminal and top in another to see the 
effect om memory.

> 
> On Wed, Sep 18, 2019 at 2:36 PM Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 9/18/19 11:32 AM, Anthony DeBarros wrote:
>      > Hi, folks -- I'm a longtime PostgreSQL user but a bit of a noob
>     when it
>      > comes to maintenance. Question:
>      >
>      > I'm running PostgreSQL 11 on Amazon RDS. Also have an EC2 box
>     running
>      > Ubuntu that runs some Python scripts that collect data into
>     PostgreSQL.
>      >
>      > We're doing the standard RDS backups. However, I'd also like to do a
>      > nightly pg_dump and store that file on S3. Is there a way to go
>     straight
>      > from RDS to S3 without having to download the dump file onto the
>     EC2 box
>      > at any point? I want to avoid a scenario where the DB file fills
>     the EC2
>      > box's disk.
> 
>     ?:
>     https://dba.stackexchange.com/questions/221454/best-way-to-pg-dump-postgresql-on-rds-to-s3
> 
>      >
>      > Thanks for any and all advice!
>      >
>      > Anthony
>      >
>      >
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Backup PostgreSQL from RDS straight to S3
  2019-09-18 18:32 Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
@ 2019-09-19 06:03 ` Steven Lembark <lembark@wrkhors.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Steven Lembark @ 2019-09-19 06:03 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org; +Cc: lembark@wrkhors.com


s3fs available on linux allows mounting S3 directly as a local 
filesystem. At that point something like:

  pg_dump ... | gzip -9 -c > /mnt/s3-mount-point/$basename.pg_dump.gz;

will do the deed nicely. If your S3 volume is something like
your_name_here.com/pg_dump then you could parallize it by dumping
separate databases into URL's based on the date and database name:

    tstamp=$(date +%Y.%m.%d-%H.%M.%S);

    gzip='/bin/gzip -9 -v';
    dump='/opt/postgres/bin/pg_dump -blah -blah -blah';

    for i in your database list
    do
        echo "Dump: '$i'";
        $dump $i | $gzip > /mnt/pg-backups/$tstamp/$i.dump.gz &
    done

    # at this point however many databases are dumping...

    wait;

    echo "Goodnight.";

If you prefer to only keep a few database backups (e.g., a rolling
weekly history) then use the day-of-week for the tstamp; if you
want to keep fewer then $(( $(date +%s) / 86400 % $num_backups)) 
will do (leap-second notwhithstanding).

Check rates to see which AWS location is cheapest for the storage
and procesing to gzip the content. Also check the CPU charges for
zipping vs. storing the data -- it may be cheaper in the long run
to use "gzip --fast" with smaller, more repeatetive content than 
to pay the extra CPU charges for "gzip --best".

-- 
Steven Lembark                                        3646 Flora Place
Workhorse Computing                                St. Louis, MO 63110
lembark@wrkhors.com                                    +1 888 359 3508





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2019-09-19 06:03 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 18:32 Backup PostgreSQL from RDS straight to S3 Anthony DeBarros <adebarros@gmail.com>
2019-09-18 18:35 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-09-18 19:04   ` Anthony DeBarros <adebarros@gmail.com>
2019-09-18 19:12     ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-09-19 06:03 ` Steven Lembark <lembark@wrkhors.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox