btrbk icon indicating copy to clipboard operation
btrbk copied to clipboard

Create backups of "/@"

Open prismplex opened this issue 5 years ago • 4 comments

First of all, thank you for this great script! Unfortunately I cannot get it to work in my environment, maybe somebody can help. I'm sure I missed something, but I don't know what.

Current output of btrfs subvolume list /

ID 1419 gen 6620027 top level 5 path timeshift-btrfs/snapshots/2019-12-05_02-37-02/@
ID 1422 gen 6620027 top level 5 path timeshift-btrfs/snapshots/2019-12-07_18-48-50/@
ID 1428 gen 6621866 top level 5 path timeshift-btrfs/snapshots/2019-12-12_03-00-02/@
ID 1431 gen 6627067 top level 5 path @
ID 1432 gen 6621866 top level 5 path timeshift-btrfs/snapshots/2019-12-14_20-00-02/@

As you see, I am using timeshift for snapshots. I like to use it in the future too, because it has an GUI and is really easy to restore snapshots with it.

My root subvolume is @ mounted at /. I read about converting the root subvolume @ to a subvolume rootfs, but I thought it should work this way too...

Current output, when running btrbk dryrun:

btrbk command line client, version 0.29.0  (Sun Dec 15 13:07:03 2019)
Using configuration: /etc/btrbk/system-backup.conf
WARNING: Skipping subvolume "//@": Failed to fetch subvolume detail
WARNING: ... sh: readlink -v -e //@
WARNING: ... readlink: //@: No such file or directory
Completed within: 0s  (Sun Dec 15 13:07:03 2019)
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.29.0)

    Date:   Sun Dec 15 13:07:03 2019
    Config: /etc/btrbk/system-backup.conf
    Dryrun: YES

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
//@
!!! Aborted: Failed to fetch subvolume detail

NOTE: Some errors occurred, which may result in missing backups!
Please check warning and error messages above.

NOTE: Dryrun was active, none of the operations above were actually executed!

Current backup-system.conf:

snapshot_dir    btrbk_snapshot

snapshot_preserve_min   2d
snapshot_preserve       14d

target_preserve_min     no
target_preserve         20d 10w *m

archive_preserve_min    latest
archive_preserve        12m 10y


volume /
  # no action if external disk is not attached
  snapshot_create  ondemand

  # propagates to all subvolume sections:
  target /mnt/347377a5-71a6-4803-a485-d0077ab1bc34/backup-system

  subvolume  @

Thank you!

prismplex avatar Dec 15 '19 12:12 prismplex

WARNING: ... sh: readlink -v -e //@
WARNING: ... readlink: //@: No such file or directory

This tells me that /@ does not exist. I guess that the subvolume @ is mounted as / on your system. You can check this by running btrbk ls -L /, it should then tell you MOUNT_SUBVOLUME=@, MOUNT_POINT=/ if I'm correct.

Just mount the root subvolume (subvolid=5) to somewhere else, so that @ is accessible from there, e.g. mount -s subvolid=5 /dev/XXX /mnt/btr_pool. Then adapt your config to volume /mnt/btr_pool, and things should work.

digint avatar Dec 16 '19 20:12 digint

Hi, I want to use this thread because I want to address the same question. However, my BTRFS layout looks different; it is based on SUSE's default layout + 1 modification for subvolid=5.

This is the output of btrbk ls -L /:

# btrbk ls -L /
MOUNT_SOURCE  ID   TOP  CGEN    GEN     UUID                                  PARENT_UUID                           RECEIVED_UUID  FLAGS     PATH
/dev/sda2     257  5    7       559099  7590c396-bb30-824d-b697-036984a63c72  -                                                   -         /
/dev/sda2     277  257  4934    559091  a62ac5e1-1fb1-304c-827e-0a87c5e045fb  -                                     -              -         //.snapshots
/dev/sda2     278  277  4954    4954    637e2171-d2ac-9f47-8f87-3896e0054541  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/1/snapshot
/dev/sda2     466  277  413821  413822  a890b67b-cedb-5743-8ad9-3c71eaaa00c6  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/102/snapshot
/dev/sda2     515  277  413948  413948  ed816b24-15c0-7741-9a90-4fa0c2ec19ac  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/109/snapshot
/dev/sda2     516  277  413954  413955  cb5cb3bc-dd1f-3549-9333-345b2caadb47  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/110/snapshot
[...]
/dev/sda2     617  277  559089  559090  489c1e41-91ae-1242-8b68-f492f923d7df  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/180/snapshot
/dev/sda2     462  277  413798  413798  47246aad-e229-2244-85ac-d5379f4816c8  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/98/snapshot
/dev/sda2     463  277  413804  413805  f6c77705-e072-8e4b-91bf-693985168b53  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/99/snapshot
/dev/sda2     268  257  33      413698  0c7f3842-30ed-a04c-bcc0-b0160c4fae2e  -                                     -              -         //boot/grub2/i386-pc
/dev/sda2     267  257  31      413941  72df5c4a-cbd0-3049-be31-346b702a0bb4  -                                     -              -         //boot/grub2/x86_64-efi
/dev/sda2     266  257  29      559091  72ec6863-e265-1945-8a11-57a6f1bf8782  -                                     -              -         //home
/dev/sda2     265  257  27      557608  f1a3603f-519c-924f-af55-58f9fb753a65  -                                     -              -         //opt
/dev/sda2     264  257  25      559114  90e343fd-3aad-e44e-919b-8193a6487f6b  -                                     -              -         //root
/dev/sda2     263  257  23      413698  da923b55-58d7-0443-9abf-cdd080190b08  -                                     -              -         //srv
/dev/sda2     262  257  21      559121  fcbfffcd-03e0-1045-8a44-259ec0a7612f  -                                     -              -         //tmp
/dev/sda2     261  257  19      430378  f0036d66-0aa1-374c-b1e5-cc682969b83f  -                                     -              -         //usr/local
/dev/sda2     259  257  15      413698  d71140d9-d5c1-9446-9a23-8c09de8a53ee  -                                     -              -         //usr/sap
/dev/sda2     260  259  17      413698  4448003f-8b86-444d-b30a-5031589dd9ab  -                                     -              -         //usr/sap/hostctrl
/dev/sda2     258  257  11      559122  6712dc5e-808f-5243-84d9-00d2067da76d  -                                     -              -         //var
/dev/sda2     550  258  430343  430344  3cf72f72-5dd3-e846-8dbe-780c4cfcbef9  -                                     -              -         //var/lib/images
/dev/sda2     268  257  33      413698  0c7f3842-30ed-a04c-bcc0-b0160c4fae2e  -                                     -              -         /boot/grub2/i386-pc
/dev/sda2     267  257  31      413941  72df5c4a-cbd0-3049-be31-346b702a0bb4  -                                     -              -         /boot/grub2/x86_64-efi
/dev/sda2     5    0    0       4038    -                                     -                                     -              -         /btrfs
/dev/sda2     257  5    7       559099  7590c396-bb30-824d-b697-036984a63c72  -                                     -              -         /btrfs/@
/dev/sda2     277  257  4934    559091  a62ac5e1-1fb1-304c-827e-0a87c5e045fb  -                                     -              -         /btrfs/@/.snapshots
/dev/sda2     278  277  4954    4954    637e2171-d2ac-9f47-8f87-3896e0054541  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/1/snapshot
/dev/sda2     466  277  413821  413822  a890b67b-cedb-5743-8ad9-3c71eaaa00c6  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/102/snapshot
/dev/sda2     515  277  413948  413948  ed816b24-15c0-7741-9a90-4fa0c2ec19ac  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/109/snapshot
/dev/sda2     516  277  413954  413955  cb5cb3bc-dd1f-3549-9333-345b2caadb47  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/110/snapshot
[...]
/dev/sda2     617  277  559089  559090  489c1e41-91ae-1242-8b68-f492f923d7df  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/180/snapshot
/dev/sda2     462  277  413798  413798  47246aad-e229-2244-85ac-d5379f4816c8  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/98/snapshot
/dev/sda2     463  277  413804  413805  f6c77705-e072-8e4b-91bf-693985168b53  7590c396-bb30-824d-b697-036984a63c72  -              readonly  //.snapshots/99/snapshot
/dev/sda2     268  257  33      413698  0c7f3842-30ed-a04c-bcc0-b0160c4fae2e  -                                     -              -         //boot/grub2/i386-pc
/dev/sda2     267  257  31      413941  72df5c4a-cbd0-3049-be31-346b702a0bb4  -                                     -              -         //boot/grub2/x86_64-efi
/dev/sda2     266  257  29      559091  72ec6863-e265-1945-8a11-57a6f1bf8782  -                                     -              -         //home
/dev/sda2     265  257  27      557608  f1a3603f-519c-924f-af55-58f9fb753a65  -                                     -              -         //opt
/dev/sda2     264  257  25      559114  90e343fd-3aad-e44e-919b-8193a6487f6b  -                                     -              -         //root
/dev/sda2     263  257  23      413698  da923b55-58d7-0443-9abf-cdd080190b08  -                                     -              -         //srv
/dev/sda2     262  257  21      559121  fcbfffcd-03e0-1045-8a44-259ec0a7612f  -                                     -              -         //tmp
/dev/sda2     261  257  19      430378  f0036d66-0aa1-374c-b1e5-cc682969b83f  -                                     -              -         //usr/local
/dev/sda2     259  257  15      413698  d71140d9-d5c1-9446-9a23-8c09de8a53ee  -                                     -              -         //usr/sap
/dev/sda2     260  259  17      413698  4448003f-8b86-444d-b30a-5031589dd9ab  -                                     -              -         //usr/sap/hostctrl
/dev/sda2     258  257  11      559122  6712dc5e-808f-5243-84d9-00d2067da76d  -                                     -              -         //var
/dev/sda2     550  258  430343  430344  3cf72f72-5dd3-e846-8dbe-780c4cfcbef9  -                                     -              -         //var/lib/images
/dev/sda2     268  257  33      413698  0c7f3842-30ed-a04c-bcc0-b0160c4fae2e  -                                     -              -         /boot/grub2/i386-pc
/dev/sda2     267  257  31      413941  72df5c4a-cbd0-3049-be31-346b702a0bb4  -                                     -              -         /boot/grub2/x86_64-efi
/dev/sda2     5    0    0       4038    -                                     -                                     -              -         /btrfs
/dev/sda2     257  5    7       559099  7590c396-bb30-824d-b697-036984a63c72  -                                     -              -         /btrfs/@
/dev/sda2     277  257  4934    559091  a62ac5e1-1fb1-304c-827e-0a87c5e045fb  -                                     -              -         /btrfs/@/.snapshots
/dev/sda2     278  277  4954    4954    637e2171-d2ac-9f47-8f87-3896e0054541  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/1/snapshot
/dev/sda2     466  277  413821  413822  a890b67b-cedb-5743-8ad9-3c71eaaa00c6  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/102/snapshot
/dev/sda2     515  277  413948  413948  ed816b24-15c0-7741-9a90-4fa0c2ec19ac  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/109/snapshot
[...]
/dev/sda2     617  277  559089  559090  489c1e41-91ae-1242-8b68-f492f923d7df  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/180/snapshot
/dev/sda2     462  277  413798  413798  47246aad-e229-2244-85ac-d5379f4816c8  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/98/snapshot
/dev/sda2     463  277  413804  413805  f6c77705-e072-8e4b-91bf-693985168b53  7590c396-bb30-824d-b697-036984a63c72  -              readonly  /btrfs/@/.snapshots/99/snapshot
/dev/sda2     268  257  33      413698  0c7f3842-30ed-a04c-bcc0-b0160c4fae2e  -                                     -              -         /btrfs/@/boot/grub2/i386-pc
/dev/sda2     267  257  31      413941  72df5c4a-cbd0-3049-be31-346b702a0bb4  -                                     -              -         /btrfs/@/boot/grub2/x86_64-efi
/dev/sda2     266  257  29      559091  72ec6863-e265-1945-8a11-57a6f1bf8782  -                                     -              -         /btrfs/@/home
/dev/sda2     265  257  27      557608  f1a3603f-519c-924f-af55-58f9fb753a65  -                                     -              -         /btrfs/@/opt
/dev/sda2     264  257  25      559114  90e343fd-3aad-e44e-919b-8193a6487f6b  -                                     -              -         /btrfs/@/root
/dev/sda2     263  257  23      413698  da923b55-58d7-0443-9abf-cdd080190b08  -                                     -              -         /btrfs/@/srv
/dev/sda2     262  257  21      559121  fcbfffcd-03e0-1045-8a44-259ec0a7612f  -                                     -              -         /btrfs/@/tmp
/dev/sda2     261  257  19      430378  f0036d66-0aa1-374c-b1e5-cc682969b83f  -                                     -              -         /btrfs/@/usr/local
/dev/sda2     259  257  15      413698  d71140d9-d5c1-9446-9a23-8c09de8a53ee  -                                     -              -         /btrfs/@/usr/sap
/dev/sda2     260  259  17      413698  4448003f-8b86-444d-b30a-5031589dd9ab  -                                     -              -         /btrfs/@/usr/sap/hostctrl
/dev/sda2     258  257  11      559122  6712dc5e-808f-5243-84d9-00d2067da76d  -                                     -              -         /btrfs/@/var
/dev/sda2     550  258  430343  430344  3cf72f72-5dd3-e846-8dbe-780c4cfcbef9  -                                     -              -         /btrfs/@/var/lib/images
/dev/sda2     266  257  29      559091  72ec6863-e265-1945-8a11-57a6f1bf8782  -                                     -              -         /home
/dev/sda2     265  257  27      557608  f1a3603f-519c-924f-af55-58f9fb753a65  -                                     -              -         /opt
/dev/sda2     264  257  25      559114  90e343fd-3aad-e44e-919b-8193a6487f6b  -                                     -              -         /root
/dev/sda2     263  257  23      413698  da923b55-58d7-0443-9abf-cdd080190b08  -                                     -              -         /srv
/dev/sda2     262  257  21      559121  fcbfffcd-03e0-1045-8a44-259ec0a7612f  -                                     -              -         /tmp
/dev/sda2     261  257  19      430378  f0036d66-0aa1-374c-b1e5-cc682969b83f  -                                     -              -         /usr/local
/dev/sda2     259  257  15      413698  d71140d9-d5c1-9446-9a23-8c09de8a53ee  -                                     -              -         /usr/sap
/dev/sda2     260  259  17      413698  4448003f-8b86-444d-b30a-5031589dd9ab  -                                     -              -         /usr/sap/hostctrl
/dev/sda2     258  257  11      559122  6712dc5e-808f-5243-84d9-00d2067da76d  -                                     -              -         /var
/dev/sda2     550  258  430343  430344  3cf72f72-5dd3-e846-8dbe-780c4cfcbef9  -                                     -              -         /var/lib/images

The top-level subvolume (with id=5) is mounted to /btrfs. Subvolumes on the next level (starting with id=257) are named @, home, var, root, etc. I'm using snapper to create snapshots (automatically) in /.snapshots.

The backups should be stored in /backup_rbd; this is a Rados Block Device (on a central software-defined storage cluster).

This block device is formatted in XFS and serves any application backups (incl. DB backups).

Question: Can I use this RBD (with XFS) for creating backups? Which volume should I use in config?

THX

cmonty14 avatar Feb 27 '20 15:02 cmonty14

Sorry for the late reply, I was very busy lately...

Can I use this RBD (with XFS) for creating backups?

No, the target need to be btrfs filesystem as well, unless you want to create raw backups (see btrbk.conf(5) TARGET TYPES for details)

digint avatar Mar 11 '20 18:03 digint

Thanks for your response.

cmonty14 avatar Mar 12 '20 10:03 cmonty14