btrfs-receive - Linux


Overview

btrfs-receive is a Btrfs command-line utility used to receive and import data into a Btrfs filesystem. It allows you to transfer data from a remote or local source and add it to the current filesystem.

Syntax

btrfs-receive [options] <device|path> <transport> <address>

Options/Flags

  • -r, –read-only: Mount the filesystem read-only after receiving data.
  • -c, –clear-cache: Clear the Btrfs cache after receiving data.
  • -f, –force: Ignore any errors while receiving data.
  • -p, –progress: Display a progress bar while receiving data.
  • -v, –verbose: Output debugging information.
  • -h, –help: Display help and usage information.

Examples

Receive data from a remote host over SSH

btrfs-receive /mnt/target ssh://user@example.com:/mnt/source

Receive data from a local file

btrfs-receive /mnt/target file:/path/to/source.img

Clear Btrfs cache after receiving

btrfs-receive -c /mnt/target file:/path/to/source.img

Common Issues

  • Permission denied: Ensure that the user has read and write permissions for the target device or file.
  • Incorrect transport or address: Verify that the provided transport (e.g., ssh, file) and address are correct.
  • Filesystem not available: Check that the target filesystem is mounted and available.

Integration

btrfs-receive can be used with other commands to automate data transfer and management tasks. For instance:

ssh example.com "btrfs send /mnt/source" | btrfs-receive /mnt/target

Related Commands

  • btrfs-send: Transfer data from a Btrfs filesystem to a remote host or local file.
  • btrfs: Manage, create, and inspect Btrfs filesystems.
  • rsync: A general-purpose command for data synchronization and backup.