Hacker News new | ask | show | jobs
by t0mas88 19 days ago
Postgres 18 has file_copy_method = clone for this, is that used underneath or did you implement your own own?
2 comments

You can use the same ZFS snapshot cloning with PostgreSQL. I've been using for a few years to test tricky db migrations with production data or to debug difficult production issues we couldn't reproduce otherwise. You take a zfs snapshot, create a zfs clone, copy the postgres config file and postgres in single user mode on the clone. It is practically instantaneous to get a clone of a prod db.
This is at the file system level. It says it uses the ZFS. Also, this is for MySQL as well, not just Postgres.
Thanks for asking! It doesn't use that. db-branch works at the filesystem level: it takes a ZFS snapshot of a cleanly shut down instance, clones it into a new dataset, and starts a separate DB process on top of it. So it doesn't depend on the Postgres version, and the same mechanism works for MySQL. Since everything happens at the filesystem layer, I think the same approach could extend to other databases and stateful services. (Thanks to killingtime74 for answering earlier, too.)