No sorry. OTOH you’d probably want to make some small shell scripts with a couple of commands each to try things out, and then use later as well:
initial_restore.sh (that runs on every startup)
incremental_backup.sh (that call on shutdown as well as from a timer)
later you can wire these in as systemd services/timers
Initial setup (also on every startup) that would get you an empty filesystem in ram first:
$ modprobe zram
$ echo 8G > /sys/block/zram0/disksize
$ mkfs.btrfs /dev/zram0
$ mkdir -p /mnt/ram_stuff
$ mount /dev/zram0 /mnt/ram_stuff
Then as a once off you’d create your subvolume for your “forever” data, in ram, and the first ever initial snapshot that you’ll backup fully (not incrementally). In the future you’d be restoring this subvolume from a backup
$ btrfs subvolume create /mnt/ram_stuff/data
$ echo "hello world $(date)" | tee /mnt/ram_stuff/data/hello.txt # ..write some stuff
$ # make a first snapshot
$ btrfs subvolume snapshot -r /mnt/ram_stuff/data /mnt/ram_stuff/snapshots.1
$ # ... send the first snapshot to a more permanent btrfs home that's not in ram
$ # assumes /data is on btrfs
$ btrfs send /mnt/ram_stuff/snapshots.1 | btrfs receive /data/backups/from_ram_stuff/
… now you’ve done the initial backup…from here on, you make new snapshots but send and receive incrementals which look like
$ echo "hello $(date)" | tee /mnt/ram_stuff/data/hello.again.txt # pretend we've changed stuff
$ btrfs subvolume snapshot -r /mnt/ram_stuff/data /mnt/ram_stuff/snapshot.2
$ # send the delta between two snapshots to /data
$ btrfs send -p /mnt/ram_stuff/snapshot.1 /mnt/ram_stuff/snapshot.2 | btrfs receive /data/backups/from_ram_stuff/
You can repeat the incremental stuff as many times as you like, but you’ll need to increment the snapshot counter, keep making new snapshots.
How do you restore? Pick the latest snapshot and send it back into empty btrfs in ram, then snapshot that without -r
which stands for readonly, to make it read-write.
$ btrfs send /data/from_ram_stuff/snapshot.2 | btrfs receive /mnt/ram_stuff/snapshot.2
$ btrfs subvolume snapshot /mnt/ram_stuff/snapshot.2 /mnt/ram_stuff/data
something along those lines. There’s plenty of docs to get the syntax right in:
https://www.kernel.org/doc/Documentation/blockdev/zram.txt
https://manpages.debian.org/testing/btrfs-progs/btrfs-subvolume.8.en.html
and you’ll need to be able to identify “the latest snapshot” using something like LATEST=$(ls -tr /mnt/ram_stuff/snapshot.* | head -n1 | cut -d. -f2)
and then do things like NEXT=$(($LATEST +1))
… probably.
also I’m not sure what happens if you have a power cut mid way, and have half a snapshot, obviously you don’t want to restore from that on startup - I forgot if you can end up with partial snapshots or not.
Who knows maybe this helps it could be pointless. It probably doesn’t hurt to try and it just boils down to doing backups and restores.