guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: btrfs recommended layout for snapshots?


From: Maxim Cournoyer
Subject: Re: btrfs recommended layout for snapshots?
Date: Tue, 15 Aug 2023 15:58:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi Efraim and others,

Efraim Flashner <efraim@flashner.co.il> writes:

> On Mon, Aug 14, 2023 at 04:41:52PM +0200, Nicolas Graves via
> Development of GNU Guix and the GNU System distribution. wrote:
>> 
>> > - either not snapshotting the rootfs / at all, with the hypothesis that
>> >   we get it back entirely from config files. Is that possible ? Is there
>> >   information in / (I think of /etc in particular) that is saved, not
>> >   temporary and not managed by guix system that would justify that we
>> >   want to snapshot / at all?
>> >   This would allow to simply care about only a few "user data"
>> >   directories, and be sure to not miss anything when there's a need to
>> >   restore the state.
>> >
>> > I can't find easily a case of successful use of the second
>> > configuration, but would be glad to find one, as well as some discussion
>> > about what would be a recommended way to secure the state beyond
>> > dotfiles.
>> 
>> I've found some equivalent information on the NixOS side here :
>> https://nixos.wiki/wiki/Impermanence
>> 
>> Some (rare) directories indeed seem that would better be saved because
>> their information is useful for the system, in the case of NixOS, it
>> seems to be "/etc/nixos", "/etc/NetworkManager" (for system
>> connections), "/var/log", "/var/lib".
>> 
>> However, I have much more files that aren't linked in the store,
>> especially in the /etc directory (at least 20 files). 
>> 
>> Has anybody tried to do something like this on Guix?
>
> I'm still not using most of the features of btrfs, just compression.

Some side topic, but an easy and useful way to leverage Btrfs snapshots
is through 'btrbk', for automatic and incremental backups.  I have mind
setup via this mcron job that fires ever hour:

--8<---------------cut here---------------start------------->8---
(define btrbk-job
  #~(job '(next-hour)
         (lambda ()
           (system* #$(file-append btrbk "/bin/btrbk")
                    "-q" "-c" #$(local-file "btrbk.conf") "run"))
         "btrbk"))
--8<---------------cut here---------------end--------------->8---

and this special extra file service:

--8<---------------cut here---------------start------------->8---
(extra-special-file "/etc/btrbk.conf" (local-file "btrbk.conf"))
--8<---------------cut here---------------end--------------->8---

that reads like:

--8<---------------cut here---------------start------------->8---
lockfile                   /var/lock/btrbk.lock
transaction_log            /var/log/btrbk.log
snapshot_dir               _btrbk_snap
stream_buffer              256m

snapshot_preserve_min   2d
snapshot_preserve       14d

target_preserve_min     no
target_preserve         20d 10w 6m

archive_preserve_min    latest
archive_preserve        12m 7y

# TODO: /etc/crypttab with automatic mounting of external drives
target /media/maxim/btr_backup/_btrbk

# TODO: Backup @root?
volume                     /mnt/btr_pool
  subvolume @home
  subvolume @data
--8<---------------cut here---------------end--------------->8---

It'd be nice to add a btrbk-service-type some day to make this easier
for people to get started.

-- 
Thanks,
Maxim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]