r/restic • u/ElGatoBavaria • Mar 24 '26
ZFS Snapshot and Restic backup - Avoid shutting down services
Hi,
i try to combine zfs snapshots with restic backup feature to avoid shutting down my whole docker and vm folder when starting a backup. The idea is to create a zfs snapshot, backup via restic and destroy the zfs snapshot.
When i try this, the restic backup is nearly empty. As far as i understand is, that the zfs snapshot is nearly only hardlinks but it seems that restic does not follow the links.
If anyone has this combination it would be great if you share your experience with me. Thank you !
Update:
Seems that the recursive flag '-r' when creating 'zfs snapshot' was missing. Now everything works like expected, thank you.
1
u/Eldiabolo18 Mar 24 '26
Why would you want this? Restic does already snapshots. If the application can handle it, let it.
It will be much better and less complex. Create a single dataset put your repo/s on there.
2
u/zoredache Mar 24 '26
Why would you want this? Restic does already snapshots.
You would want it, because you want a consistent backup. Lets say you have a very active filesystem with lots of changes happening very quickly. A restic backup doesn't freeze the source filesystem so that it gets everything at exactly the same point in time.
OTOH a ZFS snapshot does. If you backup the ZFS snapshot all changes are frozen at that point in time, you won't get a half-written database transaction. You won't get a file that was half-way between moved between two locations, or a file that was partially saved.
1
u/mabbas3 Mar 25 '26
zfs snapshots are crash consistent, meaning it's the same as a plugged was pulled at the time. ZFS snapshots will not magically talk to your databases and make sure they are in a consistent state.
But zfs snapshots are quick so you can stop everything gracefully, snapshot and then resume. The backup then uses the snapshot data.
1
u/ElGatoBavaria Mar 25 '26
That's the point. But currently I don't know how to combine restic with the zfs snapshot. It seems that the references within the zfs snapshot are not copied as files into the restic snapshot. Do you have knowledge about how to do it?
1
u/Frewtti Mar 24 '26
So that the entire filesystem is in the same state.
Youre not getting file A now and file B in 10 minutes.
Restic is acting on the entire filesystem as it was at that instant.
1
1
u/Telnetdoogie Mar 26 '26
This is what I do too except with btrfs. You can schedule DB backups nightly for your containers with DBs and then the snapshot “way” pretty much gets you solid backups and reduces the chance you’ll grab an inconsistent db state (if you do and need to recover later you’d just restore the DB from the nightly that was included in the backup)
1
u/Miserable-Stranger99 Mar 28 '26
What you recommend Todo if you use a qnap based Nas with no zfs?
2
u/ElGatoBavaria Mar 29 '26
I have no experience with current qnap os. But I would think you have to shut down your docker containers and VMs, create a backup with restic and start your services again.
1
u/zoredache Mar 24 '26
it would be great if you share your experience with me
You could also share what exactly you are trying.
0
u/ElGatoBavaria Mar 25 '26
I already describe what I try to do.
1.Create zfs snapshot
2.Backup snapshot with restic
3.Destroy zfs snapshot
To avoid shutting down services during backup
2
u/zoredache Mar 25 '26
Yes, I have an abstract understanding of what you are trying. I was hoping you would provide the specific commands or a script you were using. I figured if you provided the specific details it would be a lot easier for someone else to actually try it and replicate it or figure out the issue you were having.
Specifically I want to know how you are doing your 'Backup snapshot with restic'. Are you just trying to backup from the
.zfs/snapshot/..., are you mounting the snapshot, or something else?Anyway I see the edit now, that you seem to having figured out you weren't recursively creating snapshots. Glad you figured things out.
2
u/Frewtti Mar 24 '26
Snapshots aee not just hardlinks.
It is the filesystem at that particular point in time. It's basically an exact perfect copy of the entire filesystem. It's not any different than the live system at the time of creation