digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.62k stars 118 forks source link

Question about usage #184

Open dpantel opened 6 years ago

dpantel commented 6 years ago

After pouring over the docs, I am still unsure of how to apply btrbk in my case.

I have a btrfs volume with 'root', 'home', 'snapshots' subvolumes. I would like to make interval snapshots of both 'root' and 'home' subvolumes and store them in the 'snapshots' subvolume. Then, every few weeks, I would like to connect a btrfs-formatted backup disk from my safe and efficiently copy some of the snapshots. This would be followed by pruning of snapshots on that backup disk.

I thought I could set up btrbk to take snapshots without utilizing any backup target and then use btrbk archive on the backup disk, but from reading https://github.com/digint/btrbk/issues/90, it seems that the archive command copies snaps from target, not from snapshots location.

Any suggestions?

digint commented 6 years ago

Sorry for the late answer...

If you specify "target", and the target is not accessible, the snapshotting part is still being executed. The downside is that you'll get error messages. If you don't want this, you either need to:

I thought I could set up btrbk to take snapshots without utilizing any backup target and then use btrbk archive on the backup disk, but from reading #90, it seems that the archive command copies snaps from target, not from snapshots location.

yes, "archive" is only for targets.

dpantel commented 6 years ago

Thanks for the reply

So is there any way to utilize btrbk to intelligently (btrfs send-receive, incremental, etc) archive my local snapshots to another disk?

digint commented 6 years ago

Probably what you are looking for is something like this: https://github.com/digint/btrbk#example-laptop-with-usb-disk-for-backups

It's a bit hard for me to give general advice here, as everybody has different expectations, and there are many options to btrbk for this.

If you are unsure, play around with the options, and run btrbk --print-schedule dryrun to see what btrbk would do.

dpantel commented 6 years ago

Ok, finally got a chance to experiment. Here are some results:

Using 'target_preserve' settings for the detachable drive works, although it does generate an error message (as mentioned above). A pleasant surprise is that if there are past local snapshots available, they will be sent to the target as if the drive were connected at the time. This was not clear in the docs. From the docs, it seemed that only the 'target_preserve' settings that matched at the time of script execution would be enacted.

Using btrbk archive seems to work on local snapshots, not just targets. One caveat is that the 'archive_preserve' settings must be in the general section of the config file; archive settings in the volume/subvolume sections will be ignored.

Perhaps a useful enhancement would be to enable filters for archive.

Thanks for your help, @digint!

rickysarraf commented 6 years ago

So, for a target that is an external usb disk, btrbk takes a snapshot locally, and then fails (errors out) to do a remote backup (usb) because the disk is not attached.

@digint You mentioned to wait for 0.26.0. What feature in this version helps mitigate the error ? I have followed the laptop usb backup example, and my cron still errors out when the backup disk is not attached.

PS: In its current form, btrbk is already awesome. I'm not sure if suppressing the error (unavailability of the target usb disk) would be the right thing to do.

digint commented 6 years ago

You mentioned to wait for 0.26.0. What feature in this version helps mitigate the error?

This was related to the btrbk snapshot feature, which is now implemented.

I have followed the laptop usb backup example, and my cron still errors out when the backup disk is not attached. [...] I'm not sure if suppressing the error (unavailability of the target usb disk) would be the right thing to do.

This is "functions as designed". If a target (or source) is not accessible or fails for any other reasons, btrbk goes on with all other targets, but then returns with exit status = 10 ("Backup abort: At least one backup task aborted", see btrbk(1) EXIT STATUS). This means if you want your cron job to ignore this, you need to catch the exit code ($? in bash scripts, see contrib/cron/btrbk-mail for an example on how to do this).

Philonous commented 6 years ago

I'm using btrbk 0.26.1 with btrbk snapshot but I'm still getting

WARNING: Skipping cleanup of snapshots for subvolume "/mnt/btr_pools/ssd/rootfs", as at least one target aborted earlier

and

!!! Target "/mnt/backup/linux-ssd" aborted: Failed to fetch subvolume detail

and also an exit status of 10.

As I understood it, btrbk snapshot should only create snapshots and ignore targets alltogether, or is that wrong? I can live with the return code, but it's also not pruning old snapshots.

digint commented 6 years ago

As I understood it, btrbk snapshot should only create snapshots and ignore targets alltogether, or is that wrong?

No, this is correct. But for snapshot deletion, the target is still required in order to determine the latest snapshot/backup pair (which is always preserved in order to keep the incremental backups possible).

Added a note about this in: c65f9374735c85b29f2bfeed364b75ddb7efaa2c