Cache test database data between builds

What would be the right way to cache the test database data between builds? (Specifically for PostgreSQL, but I’d also be interested in doing this for ElasticSearch.) Running the migrations before each test run is starting to take a while, and I know from using Postgres with Docker outside of CircleCI that there should be a way to save and restore the data volume itself for reuse.

Would this help?

cache/restore the directory and mount it as a volume in your containers