postgresql 如何在运行测试后反复将AWS RDS数据库恢复到初始状态

i1icjdpr  于 2022-12-12  发布在  PostgreSQL
关注(0)|答案(2)|浏览(116)

I'm using AWS RDS Aurora Postgres 12.9.
I have a database in an "initial state" with some data on it, I want to insert/update many data on it, and then easily restore it to the "initial state" whenever I want.
For example, the solution could also be applicable to use in integration tests that uses a real database.
I'm restoring a snapshot but this takes to much time. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RestoreFromSnapshot.html
Expectation:

  • I'm OK to losse all changes after restoring to "initial state".
  • I may want to repeat this process a few times.
  • As less time I spend restoring to "initial state" as better, but It's OK to take just a few minutes.
  • Many people may want to access and manipulate data on it.

Scenario:
Setup a RDS database in "initial state" 1 - Spend some minutes manipulating many data on it. 2 - Spend some minutes analyzing the new state. 3 - Restore to "initial state" and repeat steps 1, 2, 3 without waiting to much.
Thank you.

nimxete2

nimxete21#

你 * 可以 * 这样做,但这不是进行测试的正确方法。一般来说,外部系统(如数据库)应该使用适配器进行集成,你可以将适配器取出以返回模拟响应(这可能是你的“初始状态”)。就共享对模拟的访问而言,你通常不需要:需要访问数据存储的任何人都可以运行与您相同的模拟设置,因此可以共享相同的状态,而无需共享实际的示例。

o4tp2gmn

o4tp2gmn2#

我将使用RDS“克隆”,请参见https://aws.amazon.com/blogs/aws/amazon-aurora-fast-database-cloning/
这样,我可以在大约5分钟内得到一个克隆,准备好操作它上面的数据,而不会对原始示例产生副作用。

相关问题