Incremental backups of a Linux machine to S3-compatible object storage (AWS S3, Google Cloud Storage, Cloudflare R2, Backblaze B2, MinIO, Wasabi), run as a systemd service. Written in Ecko.
Each file you back up becomes one plain object in your bucket, at its own path. You can browse the backup with any S3 tool and download a file without bit-by-bit. The daemon uploads only what changed, keeps old copies for as long as you choose, checks every week that the backup is still all there, and shows how each job is doing on a small status page.
bit-by-bit suits you if:
- you back up a Linux server or workstation that runs systemd, and want it to happen on a schedule without you thinking about it;
- you already pay for, or want, an S3-compatible bucket, and want the backup to stay readable there with ordinary tools if bit-by-bit is ever gone;
- you want recent mistakes undone (an overwritten or deleted file) as well as a lost disk recovered.
Look elsewhere (restic, Borg or Kopia, for example) if you need:
- encryption before upload. Files are stored as they are on disk. They're encrypted at rest by the provider (on by default) and in transit by HTTPS, but anyone who can read the bucket can read your files;
- deduplication or compression. A changed file is uploaded whole, and two copies of a file are stored twice;
- macOS or Windows, or a machine without systemd.
It's pre-1.0, so the config format and bucket layout may still change.
- Uploads only what changed. Each local file becomes one object. A file whose size and modification time haven't changed is not read again. A change of mode or owner alone updates the object's metadata without uploading the file.
- Keeps old copies. Before a remote file is overwritten or deleted, the
old copy is moved under
_versions/. You can restore the whole job as it was at any moment withinkeep_versions_days(30 by default). - Checks every upload. The provider checks each upload, and each part of a large one, against a SHA-256 of its content. A crash at any point leaves the backup consistent, and the next run finishes the work.
- Won't empty your backup by mistake. A missing or unreadable folder never causes remote deletes. Nor does a folder that has suddenly become empty although files were backed up from it, such as an unmounted drive.
- Checks the backup itself. Once a week the daemon lists the bucket to check that every backed-up file is there at its size. It also downloads a few files at random and checks their content. The next run uploads anything missing or wrong again.
- Restores files, links and folders. Restore puts back each file's mode, owner and modification time, recreates empty folders, and checks every file against its fingerprint.
- Shows you how it's doing.
bit-by-bit status, an optional dashboard, and a/healthzURL for an uptime monitor.
- Linux on x86-64 or arm64, with systemd. Prebuilt binaries need nothing else. Building from source needs Ecko 0.69 or later.
- A bucket on an S3-compatible provider, and an access key for it.
- Root, so the daemon can read every file you back up and restore owners.
There are four steps: get the binary, run the installer, add your settings, then run a first backup and start the service. This one line does the first two, then continue at step 3:
curl -fsSL https://raw.githubusercontent.com/sn/bit-by-bit/main/get.sh | shIt downloads the latest release for your machine, checks its SHA-256 and
runs the installer with sudo. To read the script before running it, open
get.sh. To install a particular release, set BBB_VERSION:
curl -fsSL https://raw.githubusercontent.com/sn/bit-by-bit/main/get.sh | BBB_VERSION=v0.9.0 shEach release has a prebuilt binary for x86-64 and arm64 Linux, so you don't need Ecko. This finds the latest release, downloads the build for your machine, checks its SHA-256 and unpacks it:
v=$(curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/sn/bit-by-bit/releases/latest)
v=${v##*/}
f=bit-by-bit-$v-$(uname -m)-linux.tar.gz
curl -fsSLO https://github.com/sn/bit-by-bit/releases/download/$v/$f
curl -fsSLO https://github.com/sn/bit-by-bit/releases/download/$v/$f.sha256
sha256sum -c $f.sha256
tar -xzf $f && cd ${f%.tar.gz}To build from source instead, install Ecko 0.69 or later and run this in the repo:
ecko build main.ecko -o bit-by-bitThe one dependency, the xml package, is
already in vendor/. If it's missing, ecko install restores it.
From the unpacked folder, or the repo if you built from source:
sudo ./deploy/install.shThe installer copies the binary to /usr/local/bin, puts an example config
in /etc/bit-by-bit/config.json and registers the systemd unit. It never
overwrites an existing config, and it doesn't start the service.
Put your storage keys in a file only root can read, then set the bucket, folders and schedule in the config:
sudo install -m 600 /dev/null /etc/bit-by-bit/aws.env
sudoedit /etc/bit-by-bit/aws.env # ACCESS_KEY_ID=... and SECRET_ACCESS_KEY=...
sudoedit /etc/bit-by-bit/config.json
sudo bit-by-bit check-configConfigure explains every setting, and
AWS S3 setup shows how to create the bucket and a key that
can only reach it. check-config reads the file but doesn't contact your
provider.
sudo bit-by-bit run --dry-run # logs what it would upload; sends nothing
sudo bit-by-bit run # the first full upload, in the foreground
sudo systemctl enable --now bit-by-bitThe first real run is the one that proves your keys, bucket and region work, so let it finish before you start the service. After that, the service runs each job on its schedule and starts again at every boot.
To upgrade later, repeat steps 1 and 2 with the new release, then run
sudo systemctl restart bit-by-bit. Your config and state are kept.
sudo systemctl enable --now bit-by-bit starts the daemon now and at every
boot. It runs as root, can write only to /var/lib/bit-by-bit and
/var/log/bit-by-bit, and restarts every 30 seconds if it exits, so a broken
config shows up as repeated errors in the journal, not as a stopped service.
| To | Run |
|---|---|
| Check it | systemctl status bit-by-bit, sudo bit-by-bit status |
| Follow the log | journalctl -u bit-by-bit -f (also written to /var/log/bit-by-bit/bit-by-bit.log) |
| Apply config changes | sudo systemctl reload bit-by-bit. An invalid config is rejected and the old one stays active. |
| Back up now | sudo bit-by-bit run home. A run never overlaps the daemon's run of the same job. |
| Check the backup now | sudo bit-by-bit verify home |
| Stop it | sudo systemctl stop bit-by-bit. Uploads already started finish; nothing new starts. It waits up to 60 seconds. |
| Turn it off | sudo systemctl disable --now bit-by-bit |
The config is one JSON file, /etc/bit-by-bit/config.json by default. A
complete example is in
deploy/config.example.json:
{
"state_dir": "/var/lib/bit-by-bit",
"log": { "level": "info", "file": "/var/log/bit-by-bit/bit-by-bit.log" },
"dashboard": { "listen": "127.0.0.1:8484" },
"destinations": {
"aws-main": {
"provider": "s3",
"endpoint": "https://s3.eu-west-1.amazonaws.com",
"region": "eu-west-1",
"bucket": "my-backups",
"credentials_file": "/etc/bit-by-bit/aws.env"
}
},
"jobs": [
{
"name": "home",
"destination": "aws-main",
"prefix": "laptop/home",
"paths": ["/home/me/Documents", "/home/me/Pictures"],
"exclude": ["**/node_modules/**", "**/.cache/**", "**/*.tmp"],
"schedule": { "every": "6h" }
}
]
}A destination is a bucket. A job is a set of folders backed up to one
destination on one schedule. Unknown keys are errors, so a typo never goes
unnoticed. Durations are written like 90s, 15m, 6h or 7d, and sizes
like 64MiB.
| Key | Default | Meaning |
|---|---|---|
name |
required | a-z, 0-9 and -. Used on the command line and in the bucket. |
destination |
required | The name of an entry in destinations. |
prefix |
required | Where the job's objects go in the bucket, such as laptop/home. No leading or trailing /. |
paths |
required | Absolute paths of the folders (or files) to back up. One may not contain another. |
exclude |
[] |
Globs matched against each file's full path. * matches any characters, / included, and ? one character, so **/*.tmp and *.tmp both match every .tmp file. An excluded folder isn't walked. |
schedule |
required | { "every": "6h" } (at least 1m) or { "daily_at": "02:30" } (local time). |
keep_versions_days |
30 |
How long replaced and deleted copies are kept, which is also how far back a restore can go. 0 keeps none. |
follow_symlinks |
false |
Back up what links point to, instead of the links. |
verify |
{ "every": "7d", "sample": 10 } |
How often the backup is checked (at least 1h), and how many files to download and check each time (0 to 10000). false turns checking off. |
| Key | Default | Meaning |
|---|---|---|
provider |
required | s3 for every S3-compatible provider, or gcs for Google Cloud Storage. |
endpoint |
required | The provider's URL, such as https://s3.eu-west-1.amazonaws.com. Must be https:// unless allow_insecure is set. See Providers. |
region |
required | The bucket's region. |
bucket |
required | The bucket's name. |
credentials_file |
none | A root-only file with ACCESS_KEY_ID=... and SECRET_ACCESS_KEY=.... Without one, the keys come from BBB_<NAME>_ACCESS_KEY_ID and BBB_<NAME>_SECRET_ACCESS_KEY, where <NAME> is the destination's name upper-cased with - replaced by _. |
server_side_encryption |
true |
Ask the provider to encrypt objects at rest. |
path_style |
false |
Put the bucket in the URL's path, not its host name, as MinIO needs. |
allow_insecure |
false |
Allow an http:// endpoint, for a MinIO on the same machine. |
| Key | Default | Meaning |
|---|---|---|
state_dir |
/var/lib/bit-by-bit |
Where the state database and run locks live. See State. |
log |
{ "level": "info" } |
level is debug, info, warn or error. file adds a log file next to the journal. |
concurrency |
4 |
Files uploaded at once, from 1 to 128. See below. |
multipart_threshold |
64MiB |
Files this size or larger are uploaded in parts. At most 5GiB. |
multipart_part_size |
16MiB |
The size of each part, from 5MiB to 5GiB. It grows by itself for a file that would need more than 10,000 parts. |
retry |
{ "attempts": 5, "base_delay": "2s", "max_delay": "5m" } |
How often a failed request is retried, with the wait doubling between tries. |
dashboard |
off | { "listen": "127.0.0.1:8484" } turns on the dashboard. |
- Schedules. A run missed while the machine was off happens once at
startup. A run that fails, or is cut short by a restart, is retried 15
minutes after it ended, then after 30, 60 and so on. The wait is never
longer than the job's interval.
daily_atfollows daylight-saving changes. - Excludes remove files from the backup. A file that newly matches
excludeis treated like a deleted file. Its remote copy moves to_versions/and is pruned afterkeep_versions_days. - Concurrency. Each worker takes the next file as soon as it finishes
one, so a large file holds up only its own worker. Small files are limited
by round trips to the provider, not by bandwidth. At 150 ms per request,
16 workers upload about 100 files a second, 64 about 370 and 128 about 530.
Use 32 to 64 for a distant region. Large files go up in parts, 4 at a time,
streamed from disk, so no file is held in memory. The scan before the
uploads also runs in parallel for large trees (except with
follow_symlinks).ls,restoreand--rebuild-stateuse the same number of workers. - Several jobs can share a prefix, such as one per folder of the same
machine, as long as their
pathsdon't overlap. Each job only rebuilds, prunes, lists and restores its own files. Nested prefixes (pcandpc/docs) are refused, because two jobs could then write the same object. - Changing
prefixor the destination uploads everything to the new place. Objects under the old prefix are left alone, so delete them yourself if you no longer want them. - Symlinks are backed up as links, not followed (unless
follow_symlinksis set). They keep their target exactly as written, so a relative link restores relative. A link whose target is missing is backed up too. - Checking the backup. After a run that worked, if the last check is
older than
verify.every, the daemon lists the bucket once. It checks that every backed-up file is there at its size, and that the folder list is. It then downloadsverify.samplefiles picked at random, up to 256 MiB each, and checks them against their SHA-256. Anything missing or wrong is dropped from the state database, so the next run uploads it again if it's still on the machine. A check that finds problems makes/healthzunhealthy until a later check passes. Runbit-by-bit verify <job>after the next run to clear it sooner. The listing costs one request per 1,000 objects. - Problems are files that couldn't be backed up, such as one that vanished
during the scan or changed during its upload. They make the run
partialrather thanfailed, and the next run tries those files again. A run counts every problem and keeps the text of the first 1,000 forstatusand the dashboard. The log has all of them.
Give the daemon its own IAM user whose policy covers only the backup bucket:
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow", "Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::BUCKET" },
{ "Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload"],
"Resource": "arn:aws:s3:::BUCKET/*" }
]
}aws iam create-user --user-name bit-by-bit
aws iam put-user-policy --user-name bit-by-bit --policy-name bit-by-bit-s3 \
--policy-document file://policy.json
aws iam create-access-key --user-name bit-by-bit \
--query 'AccessKey.[AccessKeyId,SecretAccessKey]' --output text |
awk '{print "ACCESS_KEY_ID=" $1 "\nSECRET_ACCESS_KEY=" $2}' |
sudo install -D -m 0600 /dev/stdin /etc/bit-by-bit/aws.envThe secret goes straight into the credentials file without being printed.
-
The region must be the bucket's region, in both
endpointandregion. A mismatch fails the run with301 PermanentRedirect. -
Bucket versioning is optional. If it's on, keep it. The policy has no
s3:DeleteObjectVersion, so a leaked key can hide objects but not destroy them. Add a lifecycle rule, or every copy bit-by-bit prunes stays stored (and billed) forever:aws s3api put-bucket-lifecycle-configuration --bucket BUCKET --lifecycle-configuration \ '{"Rules":[{"ID":"bit-by-bit-cleanup","Status":"Enabled","Filter":{}, "NoncurrentVersionExpiration":{"NoncurrentDays":90}, "AbortIncompleteMultipartUpload":{"DaysAfterInitiation":7}, "Expiration":{"ExpiredObjectDeleteMarker":true}}]}'
-
To rotate the key, create a second one, rewrite the credentials file, run
systemctl reload bit-by-bit, then delete the old key.
| Provider | Destination settings |
|---|---|
| AWS S3 | "provider": "s3", "endpoint": "https://s3.<region>.amazonaws.com", "region": "<region>" |
| Google Cloud Storage | "provider": "gcs". endpoint and region can be left out. Create HMAC keys for a service account (Cloud Storage > Settings > Interoperability) and put them in the credentials file. |
| Cloudflare R2 | "provider": "s3", "endpoint": "https://<account-id>.r2.cloudflarestorage.com", "region": "auto" |
| Backblaze B2 | "provider": "s3", "endpoint": "https://s3.<region>.backblazeb2.com", "region": "<region>" |
| Wasabi | "provider": "s3", "endpoint": "https://s3.<region>.wasabisys.com", "region": "<region>" |
| MinIO (local) | "provider": "s3", "endpoint": "http://127.0.0.1:9000", "region": "us-east-1", "path_style": true, "allow_insecure": true, "server_side_encryption": false (MinIO without a KMS rejects SSE requests) |
sudo bit-by-bit status # last run, next run and problems for each job
sudo bit-by-bit status --json # the same, for scripts
sudo bit-by-bit run home # run a job now
sudo bit-by-bit run home --dry-run # log what a run would do, change nothing
sudo bit-by-bit verify home # check the bucket holds the backup
sudo bit-by-bit verify home --sample 100 # ...and download 100 files to check them
sudo bit-by-bit ls home --at 2026-10-01T12:00:00Z
sudo bit-by-bit restore home --path /home/me/Documents --to /tmp/restore
journalctl -u bit-by-bit -p warning # problems and failuresRun them with sudo, like the daemon: the config, the credentials and the
state database are readable only by root. run and verify without a job
name act on every job. Every command takes --config <path>.
Exit codes: 0 ok, 1 failed (for verify, problems found), 2 partial (the
run finished, but some files couldn't be backed up), 64 a usage or config
error.
sudo bit-by-bit ls home --path /home/me/Documents # what a restore would produce
sudo bit-by-bit restore home --path /home/me/Documents --to /tmp/restore--tois where the restore goes, and files keep their full path under it:/home/me/Documents/a.txtcomes back as/tmp/restore/home/me/Documents/a.txt. Without--to, the restore goes to./restore-<job>-<date>-<time>. To put files back where they were, use--to /.--pathrestores one file or folder instead of the whole job.--atrestores the job as it was at that moment, using the copies kept in_versions/. It takes an RFC 3339 time, such as2026-10-12T14:00:00Zor2026-10-12T16:00:00+02:00, no further back thankeep_versions_days. Without it, you get the latest backup.- Existing files are never overwritten unless you pass
--overwrite. They are listed as skipped.
Restore checks every file against its stored fingerprint, and puts back each
file's mode and modification time. Run as root, it also puts back each file's
owner and group, by number. On another machine the same numbers may belong
to different users; --no-chown leaves the files owned by root instead. Run
as anyone else, restored files belong to that user.
Files download several at a time. Symlinks are created after every file, and
nothing is ever written through a symlink, so a tampered bucket can't make a
restore write outside --to.
Folders come back last, from the folder list in force at --at. Missing
ones, empty folders included, are created, then get their mode and
modification time (and, as root, their owner). A folder that was already
there is left as it is unless you pass --overwrite. Jobs backed up before
0.10 have no folder list until their next run. Until then, restored folders
get default permissions.
Without bit-by-bit, the backup is still a tree of ordinary objects, so
any S3 tool can download it. For example,
aws s3 cp --recursive s3://BUCKET/laptop/home/home/me/Documents ./Documents
gets the current copies, without their modes and owners.
- Extended attributes and ACLs.
- The owners of symlinks. Links are restored owned by whoever runs the restore.
- Hard links. Each name is uploaded and restored as a separate file.
- Special files: sockets, named pipes and devices. They're skipped and counted, not reported as problems.
bit-by-bit remembers what it has uploaded in the SQLite file
<state_dir>/state.db (/var/lib/bit-by-bit/state.db by default). A file
whose size and mtime match its row there is not uploaded again, and the bucket
is not checked for it.
So don't delete or change objects in the bucket by hand. Anything removed
behind bit-by-bit's back stays missing until the next check finds it (weekly
by default, or bit-by-bit verify), and the run after that uploads it again.
If the database is lost, or you're setting up a replacement machine, rebuild
it from the bucket:
sudo bit-by-bit run home --rebuild-state # only rebuilds the database, uploads nothing
sudo bit-by-bit run home # uploads whatever the bucket is missingThe daemon can serve a read-only status page. It's off unless the config has:
"dashboard": { "listen": "127.0.0.1:8484" }| URL | What |
|---|---|
http://127.0.0.1:8484/ |
The status page, described below. |
/api/status |
The same data as JSON. |
/healthz |
200 ok, or 503 listing why. Point an uptime monitor at it. |
For each job, the page shows:
- its status, and the live progress of a running backup: files done out of those planned, data sent, files per second and time left;
- how long ago its last good backup finished, and when it runs next;
- its schedule, folders and destination;
- when its backup was last checked, and anything the check found;
- the last run's changes, errors and problems, and its recent runs.
It updates in place every 3 seconds while a backup runs and every 30 seconds otherwise, while the tab is visible. "Pause updates" stops it, and without JavaScript you reload by hand. The tab icon glows green when every backup is healthy, and orange to red when one needs attention or the daemon can't be reached. The page is styled like a green-phosphor terminal. Its scanlines and glow are dropped when the system asks for more contrast.
/healthz is unhealthy when a job's last run failed, or it hasn't run for
more than twice its interval. It's also unhealthy when a running backup has
finished no file for that long, or the last check of the backup found
problems. A long run that keeps finishing files, like a first backup, stays
healthy. So does a check that couldn't finish, which is tried again after the
next run. A run with problems is noted on the page but doesn't count as
unhealthy.
The page has no login, so it only binds to loopback addresses (127.0.0.1,
localhost, ::1). To reach it from elsewhere, use an SSH tunnel
(ssh -L 8484:127.0.0.1:8484 host), or set "allow_remote": true
deliberately. The page's only control pauses its updates; it can't change
anything. If the port is taken, the daemon logs an error and keeps backing
up. Changing listen needs a service restart.
<prefix>/<absolute local path> current copy
<prefix>/_versions/<run time>/<absolute local path> copy moved aside by that run
<prefix>/_folders/<job>/<run time>.json.gz the job's folders, from that run
A run uploads a new folder list only when a folder was added, removed or
changed (mode, owner or modification time; adding or removing a file
changes its folder's time). Each list is gzipped JSON of every folder's path,
mode, owner and mtime, about 8 bytes a folder: 2.4 MB for 300,000.
Lists are pruned with the versions, except the newest one from before the
cutoff, which is still in force there. Renaming a job starts a new list.
Objects carry x-amz-meta-bbb-sha256, -mtime, -mode, -owner and
-run. Symlinks are stored as empty objects with x-amz-meta-bbb-symlink.
bbb-sha256 is the content's SHA-256. A file uploaded in parts (at least
multipart_threshold) is hashed whole and by part in one read, and each part
is sent with its hash, so the provider refuses any part that changed in
between. Files uploaded in parts before 0.7 have
mp<part size>-<SHA-256 of its parts' hex SHA-256s, joined> instead; they
still restore and verify, and get a plain SHA-256 the next time they change.
ecko test --jobs 4 # every test file, each in its own process
ecko test tests/sync_test.ecko
ecko check --strict main.ecko src/*.ecko tests/*.ecko testkit/*.eckoA few checks only root can make, like restoring files to other owners, run
in a throwaway container: tests/root/run.sh (needs Docker; builds a
scratch image from your ecko and its libraries, downloads nothing).
tests/root/run.sh tests/*.ecko runs the whole suite as root; cases that
can't run as root report SKIP. CI runs both on every push.
Tests run offline against testkit/fake_s3.ecko, an in-memory S3 server that
checks signatures, payload hashes and content-length (S3 refuses a PUT or
POST without one, even an empty one) and can be told to fail requests.
Publish a GitHub release with a tag such as v0.10.0. The release workflow
runs the checks and tests, builds on native x86-64 and arm64 Linux runners
with the Ecko version pinned in .github/workflows/release.yml, and attaches
bit-by-bit-<tag>-<arch>-linux.tar.gz and its .sha256 to the release.
MIT. Copyright (c) 2026 Sean Nieuwoudt. See LICENSE.
