Here is somewhat relevant discussion Unraid apps folder will not 100% backup - #2 by saspus
You want backup to be coherent and consistent point-in-time state of the data. Meaning, that all data has to be captured at the same time, and be in the consistent state. IF the applications that is managing said data is still running, the latter is theoretically not possible: backup captures only state of files, but state of data inside the app that hasn’t made it into a file yes is not captured.
Some applications are more susceptible to that than others.
For example, note taking apps, that keep notes on disk as separate .md files won’t care: file always contains consistent data. Stuff in memory that user edits won’t be captured until user saves the file. Backing up such application data from a filesystem snapshot with high probability will yield consistent backup.
Some databases, on the other hand, will almost guaranteed results in corrupted data. Such applications usually come with a documentation that describes how to backup its data – this usually involves dumping the state using application features, and then backing up that exported data dump, as opposed to working file. SQLie for example in journaling mode writes out journal before committing the transactions, so backing up snapshot of that data has higher chance to be useful: it can repair itself from journals. Still, exporting data and backing up said exported data is safer.
General approach shall be as follows:
- Export data from applications that support it into temporary export directory, and include it in backup. This will require reading documentation of such applications and understanding their data backup/export requirements.
- Exclude corresponding application data from backup
- Create filesystem snapshot (can be done in pre-backup script). (
man zfs-snapshot
)
- Perform backup
- Destroy the filesystem snapshot.
- Destroy the temporary export directory.
For application that are obviously using databases, don’t provide internal backup capabilities, and don’t describe how to export data – the only reliable way is to stop container, take the filesystem snapshot, and restart the container; then backup the snapshot. Most applications can tolerate half a second of downtime in the middle of the night.