We have a PostgreSQL db instance in RDS. In our application we need to run a daily export in the early hours of every day, the export and transformation may take some time and one issue we've found is it can export incorrect data if the data is being modified while the export is running (we use limit/offset as our table has ~100 million rows). This is probably a common issue.

To get over this we want to create a snapshot of our instance at midnight and use this for the export.

What's the best way to do this in RDS? Ideally the snapshot shouldn't take too long to create.

I've researched some things to try:

  • I tried to create a stored procedure to duplicate tables, but then it takes time to reindex etc, and the table name has to be different (which I want to keep the same so the query, which is used in other areas of the app, doesn't have to change).
  • RDS has read only replicas, but from brief reading they have a lag time so it seems to me they are constantly updated from the master instance. Is there any way to stop updates, or update once a day at midnight?
  • We have daily snapshots ran at midnight already, and I think we could create an AWS lambda to restore this snapshot (which I believe creates a new instance). It seems clunkier than the read-only replica but doable.
  • Use pg_dump, but this seems more work than using the AWS snapshot.

1 Answer 1


What's wrong with bullet 3? Schedule a Lambda function written in your preferred language to run at midnight that calls the RDS API to perform a snapshot.


You want this part near the bottom:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.