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.
git clone https://github.com/groenewe/bscp
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.
Bscp is similar to the classic blocksync.py, but provides the following advantages:
-C) can be enabled to shrink the
block data on the wire. On a bandwidth-limited WAN link this often
speeds the transfer up considerably; on a fast LAN it usually
slows things down, as the CPU cost of compression outweighs
the bandwidth saved — so enable it for remote/WAN copies and leave it
off on local-network transfers.
--verify) runs
b3sum (BLAKE3) on
both ends and compares the two whole-device digests — a fast,
externally re-checkable confirmation that the destination matches the
source, using an algorithm independent of the one used for block
comparison.
python3, python2/python or Perl,
so it works on ancient appliances and minimal images as well as modern
hosts.
(details)
bscp can be compiled with Nuitka into a single
self-contained executable that embeds the interpreter, so the client
host needs no Python at all.
(details)
bscp.python2 is a parallel client that runs under
Python 2.7 or 3.x, for legacy local hosts without Python 3.
(details)
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.
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).
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.
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.
https://github.com/groenewe/bscp