pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steven Lembark <lembark@wrkhors.com>
To: pgsql-general@lists.postgresql.org
Cc: lembark@wrkhors.com
Subject: Re: Backup PostgreSQL from RDS straight to S3
Date: Thu, 19 Sep 2019 01:03:44 -0500
Message-ID: <20190919010344.7f7c9bb7.lembark@wrkhors.com> (raw)
In-Reply-To: <CAAQFaFLH7WGZxBmJgkfjZy9LEQxN5L3zLnY1+KmE3AM03SHNkA@mail.gmail.com>
References: <CAAQFaFLH7WGZxBmJgkfjZy9LEQxN5L3zLnY1+KmE3AM03SHNkA@mail.gmail.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





view thread (5+ messages)

Message-ID: <20190919010344.7f7c9bb7.lembark@wrkhors.com>
Permalink:  ../20190919010344.7f7c9bb7.lembark@wrkhors.com/
Also on:    postgresql.org/message-id/20190919010344.7f7c9bb7.lembark@wrkhors.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: lembark@wrkhors.com
  Subject: Re: Backup PostgreSQL from RDS straight to S3
  In-Reply-To: <20190919010344.7f7c9bb7.lembark@wrkhors.com>
  References: <CAAQFaFLH7WGZxBmJgkfjZy9LEQxN5L3zLnY1+KmE3AM03SHNkA@mail.gmail.com> <20190919010344.7f7c9bb7.lembark@wrkhors.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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