[FIX] Make Tar from Snapshot of Changing Folder (Btrfs?)
I have BTRFS on my Ubuntu server, and I’m using PostgreSQL as a database. I’d like to make a
.tar.gz archive from the current state of the database folder.
However, since the database is of course running while doing so, it might change during creation of the
.tar. It’s around 15 GiB so it takes a while to archive it, making it likely that it will change during that time and create inconsistencies (my database automatically updates at least once per minute as it continuously fetches data from an API).
Now, I’m wondering, is there any way to
tar or at least duplicate that folder (so I can tar it later) atomically?
My current idea is to somehow make a BTRFS snapshot and then tar that folder out of the snapshot and then delete the snapshot.
How would I accomplish the goal of making a tar that accurately represents a single point in time, as opposed to including conflicting changes while the database updates?
Is there an easier, alternative method that I’m not considering here?