Announcement

Collapse
No announcement yet.

taking snapshots manually

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    taking snapshots manually

    I'm wondering if I'm missing something with my understanding of taking snapshots manually.

    I'm doing some experimenting with the recent post's idea of booting multiple distos from a single btrfs partition.

    In this test I'm working with Windows Managers and not Desktop environments and I'm following some guides more or less.

    One is on Debian 12 and one is on Archlinux so I'm using EndeavourOS to make the install easier.

    My current subvolume map looks like this:
    Code:
    sudo btrfs su list /
    [sudo] password for jim:
    ID 256 gen 7864 top level 5 path @deb
    ID 257 gen 7504 top level 5 path @deb_home
    ID 258 gen 5800 top level 5 path @hypr
    ID 259 gen 5800 top level 5 path @hypr_home
    ID 260 gen 5800 top level 5 path @hypr_cache
    ID 261 gen 5800 top level 5 path @hypr_log
    ID 262 gen 336 top level 258 path @hypr/var/lib/portables
    ID 263 gen 337 top level 258 path @hypr/var/lib/machines
    ID 264 gen 869 top level 256 path var/lib/portables
    ID 265 gen 870 top level 256 path var/lib/machines
    ID 266 gen 5365 top level 5 path @snapshots
    ID 267 gen 5334 top level 266 path @snapshots/eos-hypr/root/@hypr-20230803_11:30
    ID 268 gen 5336 top level 266 path @snapshots/eos-hypr/home/@hypr_home-20230803_11:30
    ID 269 gen 5365 top level 266 path @snapshots/debian/root/@deb-20230803-1134
    ID 270 gen 5366 top level 266 path @snapshots/debian/home/@deb_home-20230803-1134
    ​So Debian has @deb and @deb_home, while Arch has the ones that start with @hypr.

    I created the @snapshots to store my snapshots for both distros

    My method is what I'm questioning. While booted into Debian I mounted /dev/nvne0n1p2 to a tmp directory like /mnt.

    When I cd /mnt I see:
    Code:
    root@den-pc:/mnt# ls -l
    total 0
    drwxr-xr-x 1 root root 280 Jul 31 09:14 @deb
    drwxr-xr-x 1 root root 18 Jul 31 16:31 @deb_home
    drwxr-xr-x 1 root root 122 Jul 31 10:44 @hypr
    drwxr-xr-x 1 root root 90 Jul 31 14:19 @hypr_cache
    drwxr-xr-x 1 root root 6 Jul 31 10:45 @hypr_home
    drwxr-xr-x 1 root root 252 Aug 3 17:44 @hypr_log
    drwxr-xr-x 1 root root 28 Aug 3 11:21 @snapshots
    ​Here' how I manually create the snapshots:
    Code:
    /mnt# btrfs su sn -r @deb @snapshots/debian/root/@deb-20230805-0546
    Create a snapshot of '@deb' in '@snapshots/debian/root/@deb-20230805-0546'
    I repeated the concept for the @deb_home.

    It got me thinking that it really didn't matter which distro I was booted into, all the subvolumes could be snapshotted at the same time.

    Code:
    cd /mnt
    btrfs su sn -r @deb @snapshots/debian/root/@deb-20230805-0546
    btrfs su sn -r @deb_home @snapshots/debian/home/@deb_home-20230805-0546
    btrfs su sn -r @hypr @snapshots/eos-hypr/root/@hypr-20230805-0551
    btrfs su sn -r @hypr_home @snapshots/eos-hypr/home/@hypr_home-20230805-0551
    ​I've seen folks do their snapshots by referencing the directory structure for their source and not the actual subvolume. For example
    Code:
    btrfs su sn -r / @snapshots/test/@_20230805
    Produces a R/O snapshot of the root, "/", directory of the currently booted system.

    I can't see any real difference between:
    Code:
    btrfs su sn -r / @snapshots/test/@_20230805
    and
    btrfs su sn -r @deb @snapshots/test/@_20230805
    if I'm booted into the Debian distro.

    Thoughts ?

    Jim A





    Last edited by jfabernathy; Aug 05, 2023, 06:49 AM.

    #2
    Originally posted by jfabernathy View Post
    I can't see any real difference between:
    Code:
    btrfs su sn -r / @snapshots/test/@_20230805
    and
    btrfs su sn -r @deb @snapshots/test/@_20230805
    (Note that those commands use the current directory of the shell, which I presume is the fs root of the btrfs. Both use the current directory for the target, and the second for the source as well.)

    With btrfs one usually names a subvolume by the directory where it is reached by a current mount. In Linux a directory can be referred to in several ways, especially when it is mounted more than once, as is typical with btrfs. When booted to the install in @deb, @deb is mounted on /, so both commands refer to the same directory and so the same subvolume.

    If I'm writing a script using btrfs commands I try to be consistent, to avoid confusing myself. Either the script changes directory to the btrfs top level before doing much, or full paths from the same mount are used throughout.
    Regards, John Little

    Comment


      #3
      What jlittle says, and ...

      From /etc/fstab:
      # <file system> <mount point> <type> <options> <dump> <pass>
      # / was on /dev/sda3 during installation
      UUID=8031d05e-03c9-4012-ab07-89ef71983232 / btrfs defaults,subvol=@rootfs 0 0
      ...
      I don't have a @home because I moved everything from @home to /mnt/@rootfs/home and then deleted @home and took it out of the /etc/fstab table. I only have to snapshot @ to archive my entire system.



      jerry@GreyGeek:~$ sudo btrfs su list /
      ID 268 gen 24796 top level 5 path @rootfs
      ID 269 gen 14600 top level 5 path snapshots/@202307302006
      ID 270 gen 16042 top level 5 path snapshots/@202307312047
      ID 271 gen 17488 top level 5 path snapshots/@202308011908
      ID 272 gen 19214 top level 5 path snapshots/@202308022104
      ID 273 gen 20873 top level 5 path snapshots/@202308032224
      ID 274 gen 22461 top level 5 path snapshots/@202308042139
      ID 275 gen 23927 top level 5 path snapshots/@202308051937
      When my script creates those snapshots it also uses "btrfs send -p" to forward them to a removable SSD and to an internal nvme drive.

      jerry@GreyGeek:~$ sudo vdir /
      total 56
      drwxr-xr-x 1 root root 0 Jul 21 20:41 backup
      lrwxrwxrwx 1 root root 7 Jul 21 16:24 bin -> usr/bin
      drwxr-xr-x 1 root root 394 Aug 3 23:19 boot
      -rwxr-xr-x 1 root root 1100 Nov 1 2022 btrfs_subvol_diff.sh
      drwxr-xr-x 20 root root 3720 Aug 6 17:04 dev
      drwxr-xr-x 1 root root 4182 Aug 6 17:04 etc
      drwxr-xr-x 1 root root 10 Jul 21 16:28 home
      .....

      jerry@GreyGeek:~$ sudo mount /dev/sda3 /mnt
      jerry@GreyGeek:~$ sudo vdir /mnt
      total 0
      drwxr-xr-x 1 root root 352 Jul 26 19:39 @rootfs
      drwxr-xr-x 1 root root 182 Aug 5 19:37 snapshots


      If one creates snapshots under "/" or "/home/acctname" then those snapshots are visible inside the filesystem. Timeshift and snapper do it that way. They use complicated file structures, sometimes mimicking them under /run. It's usually an alternating file structure:
      @/snapshots/1/snapshot/@yyyymmdd ...
      @/snapshots/2/snapshot/@yyyymmdd ...
      etc...

      IF you uninstall Timeshift before you delete all your snapshots you are in for a world of hurt (from my own experience), blowing away a snapshot that you are standing on and having your entire system disappear. Snapper is, IMO, a much better tool, although it isn't a GUI tool. You have a much finer control over snapshots and their internal files.

      If one mounts the /dev/sdaN btrfs drive to /mnt then /mnt/@ and /mnt/snapshots/@yyyymmddhhmm become visible. One can "mv /mnt/@ /mnt/@old" and then "btrfs sn /mnt/snapshots/yyyymmddhhmm /mnt/@" and reboot, which rolls the system back to @yyyymmddhhmm.

      A word of caution. Btrfs devs have stated that creating more than about 12 snapshots per subvolume is to be avoided because the potential exists for the oldest snapshots to grow in size and fill up the btrfs pool.
      Last edited by GreyGeek; Aug 07, 2023, 07:56 AM.
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        I think the direct answer to your question is - there is no difference except where (which subvolume) you're snapshotting from. The first works if you're booted into @deb, but the results would vary depending on where you are booted. I personally would avoid the potential confusion and keep the commands clear.

        On a different note, I think subvolume nesting is an unnecessary complication and fraught with difficulty. I see no benefit to doing it. I suppose if one had 5 snapshots inside another snapshot and wanted to send|receive all 5, one could use a single send|receive command of the top level subvolume. Not a need that exists in my world. I simply use a snapshots folder on the root file system, but each to his own I guess.
        Last edited by oshunluvr; Aug 07, 2023, 07:34 AM.

        Please Read Me

        Comment

        Working...
        X