Bscp – Secure and efficient copying of block devices

Bscp copies a single file or block device over an SSH connection, transferring only the parts that have changed.

In other words, it handles the edge case where rsync fails.

This is a fork. It builds on, and is inspired by, the original bscp by Volker Diels-Grabsch (vog/bscp). See Credits below.

Download

git clone https://github.com/groenewe/bscp

Usage

bscp [options] SRC DST

Exactly one of SRC and DST is a remote HOST:path; which side carries the HOST: prefix decides the direction:

push:  bscp local_file        HOST:remote_file
pull:  bscp HOST:remote_file  local_file

SRC and DST may each be a regular file or a block device, and the destination must already exist. Blocks are 64 KiB and hashed with SHA-256 by default. For the full list of options — block size, hash algorithm, resume, retries, dry-run, multi-threaded hashing and more — see the README.

Comparison

Bscp is similar to the classic blocksync.py, but provides the following advantages:

Portability

Use cases

Off-site disk imaging

Pull a remote machine's whole system disk — virtual or physical — into a local image file over nothing but SSH. Useful when a budget hoster (e.g. Strato.de) offers no backup or snapshot facility of its own. The first run images the whole disk; every later run copies only the blocks that changed.

bscp -C root@server:/dev/vda /mnt/backup/server-vda.img

-C turns on SSH compression — worthwhile over a WAN link like this, where bandwidth is the bottleneck; drop it for fast local-network copies.

To image a live root device consistently, boot the remote host with a read-only root using overlayroot (kernel parameter overlayroot=tmpfs:recurse=0, added via a dedicated GRUB entry in /boot/grub/custom.cfg). All writes go to a tmpfs overlay, so the underlying device stays frozen while you image it.

SSD-friendly incremental backups

Because only modified blocks are written, the destination device sees far fewer writes than a full-copy tool would issue — extending the service life of a backup SSD (finite program/erase cycles), and running faster too (writing is slower than reading, and Bscp writes only the differences).

Compressed, sparse, mountable images

Write the image onto a compression-enabled filesystem (ZFS, bcachefs, btrfs), into a pre-created sparse file. Filesystem compression shrinks the image, and all-zero blocks — unused regions of the source disk — are stored as holes, so empty space costs nothing. The result stays an ordinary file, so it can be loop-mounted and browsed to inspect it or selectively restore individual files or whole directory trees with cp, rsync or scp — no full restore needed.

Credits

This is a fork of bscp, originally created by Volker Diels-Grabsch and contributors. That work inspired and forms the basis of this version. All original copyright notices are retained, and the software remains under its original ISC-style license.

Contact

See also