linuxmint / timeshift

System restore tool for Linux. Creates filesystem snapshots using rsync+hardlinks, or BTRFS snapshots. Supports scheduled snapshots, multiple backup levels, and exclude filters. Snapshots can be restored while system is running or from Live CD/USB.
2.52k stars 91 forks source link

btrfs snapshot should be read-only? #64

Open applike-ss opened 2 years ago

applike-ss commented 2 years ago

Is your feature request related to a problem? Please describe. I would like to be able to backup my btfs snapshots.

Describe the solution you'd like To be able to backup my snapshots, i would like to use something like this:

sudo btrfs send -ve "/timeshift-btrfs/snapshots/2022-09-23_08-42-09/@" | sudo btrfs receive /external-backups
sudo btrfs send -ve "/timeshift-btrfs/snapshots/2022-09-23_08-42-09/@home" | sudo btrfs receive /external-backups

until there is an option in timeshift that allows to backup to a different drive via btrfs directly.

Describe alternatives you've considered use rsync mode - but that is a slooooow solution

Additional context when using the mentioned method i get an error. I am not 100% sure if i am actually doing it right, as i'm new to btrfs.

$ sudo btrfs send -ve "/timeshift-btrfs/snapshots/2022-09-23_08-42-09/@" | sudo btrfs receive /external-backups
> ERROR: unable to resolve /timeshift-btrfs/snapshots/2022-09-23_08-42-09/@
> ERROR: empty stream is not considered valid
mtwebster commented 2 years ago

Have you tried running it directly as root (without sudo)?

If you don't have a root pw setup you should be able to just sudo su.

applike-ss commented 2 years ago

Why should that make a difference? I did not try it, however it doesn't make sense to me if it would work then.

emanuc commented 2 years ago

To start a Btrfs snapshot to the Backup subvolume, the snapshot must be read only, the options to do so are 2: 1) Create a read-only snapshot, use the "-r" option: sudo btrfs subvolume snapshot -r timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ /@_backup 2) Set the snapshot read-only: sudo btrfs property set timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ ro true If you want to restore the snapshot with Timeshift, you have to remember to edit it in RW: sudo btrfs property set timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ ro false

It would be nice if Timeshift created the snapshots as read only to protect them from writing and to be able to take advantage of "btrfs send | receive". Find more details here: Find more details here: https://btrfs.wiki.kernel.org/index.php/Incremental_Backup

applike-ss commented 2 years ago

To start a Btrfs snapshot to the Backup subvolume, the snapshot must be read only, the options to do so are 2:

  1. Create a read-only snapshot, use the "-r" option: sudo btrfs subvolume snapshot -r timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ /@_backup
  2. Set the snapshot read-only: sudo btrfs property set timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ ro true If you want to restore the snapshot with Timeshift, you have to remember to edit it in RW: sudo btrfs property set timeshift-btrfs/snapshots/2022-09-23_08-42-09/@ ro false

It would be nice if Timeshift created the snapshots as read only to protect them from writing and to be able to take advantage of "btrfs send | receive". Find more details here: Find more details here: https://btrfs.wiki.kernel.org/index.php/Incremental_Backup

Thanks, this explains it nicely! Hope the devs will make this a feature, as otherwise i only have on-device backups. That's a problem if lets say your ssd gets corrupted in any way.