Skip to content

CLI reference

Backup and restore btrfs subvolumes using btrfs-progs.

Usage:

$ b4 [OPTIONS] COMMAND [ARGS]...

Options:

  • -c, --config PATH: Path to the config file [default: ~/.config/b4_backup.yml]
  • -o, --option TEXT: Override values from the config
  • -v, --version: Print the current version and exit
  • --help: Show this message and exit.

Commands:

  • backup: Perform backups on specified targets.
  • list: List all snapshots for the specified targets.
  • clean: Apply the targets retention ruleset...
  • delete: Delete a specific snapshot from the source...
  • delete-all: Delete all local and remote backups of the...
  • restore: Restore one or more targets based on a...
  • sync: Send pending snapshots to the destination.
  • tools: Helpful cli commands, that are too...

b4 backup

Perform backups on specified targets. If no target is specified, the default targets defined in the config will be used.

Usage:

$ b4 backup [OPTIONS]

Options:

  • -t, --target TEXT: Selected targets to backup
  • -n, --name TEXT: Name suffix (and retention ruleset) for this backup [default: manual]
  • --source-only / --no-source-only: Perform actions on source side only [default: no-source-only]
  • --help: Show this message and exit.

b4 list

List all snapshots for the specified targets.

Usage:

$ b4 list [OPTIONS]

Options:

  • -t, --target TEXT: Selected targets to backup
  • --source / --no-source: List snapshots on source host [default: no-source]
  • --destination / --no-destination: List snapshots on destination host [default: no-destination]
  • --format [rich|json|raw]: Output format [default: rich]
  • --help: Show this message and exit.

b4 clean

Apply the targets retention ruleset without performing a backup.

Usage:

$ b4 clean [OPTIONS]

Options:

  • -t, --target TEXT: Selected targets to backup
  • --source-only / --no-source-only: Perform actions on source side only [default: no-source-only]
  • --help: Show this message and exit.

b4 delete

Delete a specific snapshot from the source and/or destination.

Usage:

$ b4 delete [OPTIONS] SNAPSHOT_NAME

Arguments:

  • SNAPSHOT_NAME: Name of the snapshot you want to restore [required]

Options:

  • -t, --target TEXT: Selected targets to backup
  • --source / --no-source: Delete from source host [default: no-source]
  • --destination / --no-destination: Delete from destination host [default: no-destination]
  • --help: Show this message and exit.

b4 delete-all

Delete all local and remote backups of the specified target/retention ruleset combination. Equivalent to an "all: 0" rule.

Usage:

$ b4 delete-all [OPTIONS]

Options:

  • -t, --target TEXT: Selected targets to backup
  • -r, --retention TEXT: Name suffix (and retention ruleset) for this backup [default: ALL]
  • --force / --no-force: Skip confirmation prompt [default: no-force]
  • --source / --no-source: Delete from source host [default: no-source]
  • --destination / --no-destination: Delete from destination host [default: no-destination]
  • --help: Show this message and exit.

b4 restore

Restore one or more targets based on a previously created snapshot. You can revert a REPLACE restore by using REPLACE als snapshot name and strategy.

Usage:

$ b4 restore [OPTIONS] SNAPSHOT_NAME

Arguments:

  • SNAPSHOT_NAME: Name of the snapshot you want to restore [required]

Options:

  • -t, --target TEXT: Selected targets to backup
  • --strategy [safe|replace]: Restore strategy or procedure to apply
  • --source-only / --no-source-only: Perform actions on source side only [default: no-source-only]
  • --help: Show this message and exit.

b4 sync

Send pending snapshots to the destination.

Usage:

$ b4 sync [OPTIONS]

Options:

  • -t, --target TEXT: Selected targets to backup
  • --help: Show this message and exit.

b4 tools

Helpful cli commands, that are too specific to be in the main part of the code.

Some parts here may be untested.

Usage:

$ b4 tools [OPTIONS] COMMAND [ARGS]...

Options:

  • --help: Show this message and exit.

Commands:

  • dump-config: Return the fully interpolated configuration.
  • update-config: Updates the b4 config based on the new...

b4 tools dump-config

Return the fully interpolated configuration. For debugging.

Usage:

$ b4 tools dump-config [OPTIONS]

Options:

  • --help: Show this message and exit.

b4 tools update-config

Updates the b4 config based on the new targets list parameter.

Targets that are not mentioned in the new targets list, aren't removed, but the source attribute will become None, until every backup is eventually deleted or cleaned.

You need to provide the config updates in a format like this:

ruaml.yaml required.

Usage:

$ b4 tools update-config [OPTIONS] NEW_TARGETS

Arguments:

  • NEW_TARGETS: JSON object containing 'target_name: source' [required]

Options:

  • --dry-run / --no-dry-run: Just print the new config instead of actually updating the config file [default: no-dry-run]
  • --delete-source / --no-delete-source: Delete all backups on source side [default: no-delete-source]
  • --help: Show this message and exit.