BitTwin
Verified, bit-for-bit folder synchronization.
- LinuxUbuntu, Debian, Arch
- Version
- build f1b6615
- Updated
- License
- GPL-3.0
- Built with
- Python
- Downloads
- 1
- Mirror
What it does
BitTwin syncs folders between internal disks, USB drives and SFTP servers — and proves every byte arrived. Each copy is hashed on the way in, fsynced, read back from the drive and hashed again, and the source is re-read to catch flaky cables. Only then is it atomically renamed into place, so a power cut can never leave a half-written file.
- SHA-256 verified read-back of every copy
- Atomic replace — never a half-written file
- Local disks, USB drives and SFTP
- Fully manual: no daemon, no scheduler, no account
Supported systems
- LinuxUbuntu, Debian, Arch
Downloads build f1b6615
How to verify a download
Every file is hashed as it is mirrored. Drop a file you downloaded here and your browser checks it locally — nothing is uploaded.
Or compare the checksum with the one your system computes:
# Linux
sha256sum BitTwin-f1b6615-source.zip
# macOS
shasum -a 256 BitTwin-f1b6615-source.zip
# Windows (PowerShell)
Get-FileHash BitTwin-f1b6615-source.zip -Algorithm SHA256
Changelog
Optionally save SFTP passphrases in KDE Wallet (v1.2.0)
f1b6615 ·Test SFTP server: create files with owner-only permissions
21465f0 ·Fix Ubuntu 24.04 support and make CI findings visible
6299b4b ·Security hardening and public CI checks (v1.1.0)
7ba0898 ·Fix combo box border being clipped on the right edge
1e8cf6e ·BitTwin 1.0: verified bit-for-bit folder sync for Kubuntu
36e34a0 ·Initial commit
d0f8b2d ·
Documentation
BitTwin
Verified, bit-for-bit folder synchronization for Linux.
Sync folders between internal disks, USB drives and SFTP servers, and know that every byte arrived exactly as it left.
Why BitTwin?
Most sync tools trust that a write succeeded. BitTwin doesn't. Every file it copies goes through the same checks before it's allowed to replace anything:
- The source is streamed into a hidden temporary file next to the destination, and its SHA-256 is calculated on the way.
- The temp file is flushed and
fsynced so the data is physically on the drive, then dropped from the Linux page cache. - The copy is read back from the drive and hashed again. Both hashes must match bit for bit.
- (on by default) The source is read a second time, also bypassing the cache, to catch failing drives and flaky USB cables that return different data on each read.
- Only then is the file's date and permissions applied and the temp file atomically renamed into place.
If any check fails, the temp file is thrown away and the copy is retried. If it keeps failing, the existing destination file is left untouched and the problem is reported. A power cut or unplugged drive in the middle of a sync can never leave a half-written file in place of a good one.
BitTwin is fully manual. It has no background service, no scheduler, no accounts and no telemetry. It only does something when you press a button.
Features
| Three sync modes | Mirror, Update and Two-way (see below) |
| Two side-by-side panels | Each side shows the selected folder, drive or server at the top, with free space |
| Drives menu | One click to pick any mounted USB drive, SSD or partition |
| SFTP support | Sync with a remote server or cloud drive over SSH using your private key file + passphrase (or a password) |
| Preview before sync | Compare first and see every planned copy, removal and conflict. Right-click any row to change what happens |
| Bit-for-bit verify | The Verify bit for bit button hashes both sides and proves they're identical |
| Safety archive | Replaced and removed files are moved to .bittwin-archive/<date>/, not deleted |
| Conflict detection | Two-way mode remembers the last sync and flags files changed on both sides |
| Logs | Every run writes a log with each copied file's verified SHA-256 |
| Native look | Qt 6, Breeze icons, follows your light/dark theme |
Quick start
BitTwin is built for Kubuntu and is tested automatically on Ubuntu 24.04 LTS and 26.04 LTS. It works on any Ubuntu/Debian system with KDE or GNOME. It uses the Qt and SSH libraries that ship with the distribution, so there's no pip and no virtual environment.
git clone https://github.com/narl3yyy-svg/BitTwin.git
cd BitTwin
./run.sh./run.sh: try it without installing
run.sh runs BitTwin straight from the folder. Nothing is installed or changed on your system.
- Checks that Python 3, PyQt6 and Paramiko are present (and offers to
apt installthem if not). - Runs the built-in self-test suite: real copies, simulated corruption, cancellation and a real SFTP server with a passphrase-protected key.
- Starts the app.
./run.sh # self-test, then start
./run.sh --no-test # start immediately
./run.sh --test # only run the self-tests
./run.sh ~/Photos /media/$USER/Backup/Photos # start with both sides filled in./install.sh: install it when you like it
./install.sh # install or update (for your user, no root needed)
./install.sh --uninstall # remove BitTwin, keep settings & logs
./install.sh --purge # remove BitTwin and all its settings, logs and historyThe installer runs the self-tests first, then adds:
- the program in
~/.local/share/bittwin - a
bittwincommand in~/.local/bin - BitTwin in your application menu (Utilities), with its icon
Dependencies (installed automatically if missing)
# Ubuntu / Kubuntu 25.04 and newer
sudo apt install python3 python3-pyqt6 python3-paramiko python3-keyring qt6-svg-plugins openssh-client
# Ubuntu / Kubuntu 24.04 LTS
sudo apt install python3 python3-pyqt6 python3-paramiko python3-keyring libqt6svg6 openssh-clientHow to use
- Choose the left side. Click Folder…, pick a drive from Drives, connect with SFTP…, or just drag a folder onto the panel.
- Choose the right side the same way. The ⇄ button swaps the two sides.
- Pick a mode at the top (and a direction for Mirror and Update).
- Press Compare (
F5). Nothing is changed yet; you get a full preview. - Review the list. Use the filters (Changes, Needs attention, All, Identical) and the search box. Right-click any row to copy the other way, remove, or skip it.
- Press Synchronize (
Ctrl+Enter), check the summary, and confirm. - When it finishes, BitTwin compares again automatically to confirm both sides match. For complete certainty, press Verify bit for bit.
Sync modes
| Mode | What it does | Deletes? |
|---|---|---|
Mirror → / ← |
Makes the target an exact copy of the source. New and changed files are copied; files that exist only on the target are removed. | Yes, on the target (archived by default) |
Update → / ← |
Copies files that are new or newer on the source. If the target's file is newer it's left alone and flagged. | Never |
Two-way ⇄ |
Keeps both sides identical. Edits, new files and deletions on either side are carried to the other. | Yes, deletions are propagated (archived by default) |
How two-way sync tells a deletion from a new file: after each sync BitTwin remembers what
both sides looked like (stored locally in ~/.local/state/BitTwin/pairs/). The next time, a
file missing on one side that is unchanged on the other was deleted on purpose, so it's
removed from the other side too. On the very first two-way sync there's no history, so
BitTwin never deletes anything; it only adds what's missing on each side.
Conflicts. If a file was changed on both sides since the last sync, it's marked ⚠ Conflict. By default the newer file wins and the older one goes to the archive. You can change that per file (right-click) or turn it off in Settings so conflicts are skipped until you decide.
SFTP (remote servers and cloud drives)
Click SFTP… on either side:
| Field | |
|---|---|
| Host / Port | Server address and SSH port (usually 22) |
| Username | Your account on the server |
| Sign in with | Private key file (recommended) or Password |
| Key file | Your private key, e.g. ~/.ssh/id_ed25519 (not the .pub file). Ed25519, ECDSA and RSA keys are supported |
| Key passphrase | The passphrase that unlocks the key. Leave it empty if the key has none |
| Save passphrase in KDE Wallet | Optional. Tick it so you don't have to type the passphrase every time (see below) |
| Remote folder | The folder on the server. Click Browse… to pick it from the server's folders |
- Test connection checks everything before you use it.
- The first time you connect to a server, BitTwin shows its host-key fingerprint
and asks you to confirm it. Trusted servers are remembered in
~/.config/BitTwin/known_hosts, and keys from your~/.ssh/known_hostsare recognised too. - If a server's key changes, BitTwin refuses to connect and warns you (possible man-in-the-middle).
- Your passphrase is only saved if you ask. By default it stays in memory until you close
BitTwin. If you tick Save passphrase in KDE Wallet, it's stored encrypted in KDE Wallet
(or GNOME Keyring on GNOME), the same place your desktop keeps Wi-Fi and browser passwords.
BitTwin's own settings file only ever holds the host, port, user, key path and folder.
- It's saved only after a connection with it succeeds, so a typo is never stored.
- Untick the box and press Use this server to delete it from the wallet again.
- You can also see or remove it in KDE Wallet Manager under BitTwin SFTP.
- If no secure password store is available, the option is greyed out. BitTwin never falls back to saving secrets as plain text.
- Copies to and from SFTP are verified by reading the uploaded file back over the
connection and comparing SHA-256 hashes. BitTwin also asks the server to
fsyncthe file (OpenSSH supports this).
Settings
Open them from the ☰ menu at the top right.
| Setting | Default | |
|---|---|---|
| Compare by | Size + date | Switch to bit for bit to hash every file during each compare (slow, exact) |
| Time tolerance | 2 s | FAT/exFAT drives and SFTP store coarse timestamps |
Keep replaced/removed files in .bittwin-archive |
On | Recover anything a sync replaced or removed |
| Re-read the source after every copy | On | Catches failing drives and cables; costs one extra read |
| Retries after a failed verification | 2 | |
| Two-way: newer file wins conflicts | On | Turn off to skip conflicts until you decide |
| Exclude patterns | .Trash-*, lost+found, … |
One per line. Matches names or paths (*.tmp, node_modules, cache/*) |
| Theme | Follow system | Light / Dark / System |
Where things are stored
| Settings & saved connections | ~/.config/BitTwin/ |
| Run logs (with SHA-256 of every copied file) | ~/.local/state/BitTwin/logs/ (also available from ☰ → Open logs folder) |
| Two-way sync history | ~/.local/state/BitTwin/pairs/ |
| Archived files | .bittwin-archive/<date_time>/ inside the synced folder |
Nothing is ever sent anywhere except to the SFTP servers you connect to yourself.
Good to know
- Symbolic links are listed but never followed or copied, so a link can't pull files from outside the folder into the sync.
- Empty folders are synced. Special files (sockets, device nodes) are ignored.
- Permissions are copied where the destination supports them. FAT/exFAT/NTFS drives don't, which is harmless; the file contents are what's verified.
- If a source file changes during the copy, BitTwin notices, discards the copy and retries. If it changed since the comparison, it asks you to compare again.
- Cancel stops safely after the current file. Files already copied are complete and verified; the one in progress is discarded.
- To restore something from the archive, open
.bittwin-archivein Dolphin (pressCtrl+Hto show hidden folders) and copy it back.
Security & privacy
BitTwin is designed to be safe to run on your own files:
| Stays in its lane | Only reads and writes inside the two folders you choose. File names from servers are validated (/, .. and similar tricks are rejected), symbolic links are never followed, and BitTwin refuses to write through a folder that is a symbolic link. |
| No phoning home | No telemetry, no update checks, no accounts, no background service. The only network connections are to SFTP servers you add. |
| No root | Runs as your user. install.sh installs into your home folder and asks first before using sudo apt for missing Ubuntu packages. |
| Secrets stay secret | SSH passphrases and passwords stay in memory, unless you choose to save them encrypted in KDE Wallet / GNOME Keyring. They're never written to BitTwin's own files. Settings, logs and sync history are private to your account (0700 / 0600). |
| Server identity | You confirm a new SFTP server's fingerprint once. If it ever changes, BitTwin refuses to connect. |
| Safe display | File names are always shown as plain text, so a crafted name can't inject content into the window. |
| Checked on every change | The test suite (including attack tests: malicious SFTP server, symlink escapes, crafted names) runs on Ubuntu 24.04 and 26.04, along with CodeQL, Bandit and ShellCheck. Results are public in the Actions tab. |
Found a security problem? Please report it privately as described in SECURITY.md.
Verifying a download
Each release comes with a SHA256SUMS file. After downloading both files into the same folder:
sha256sum -c SHA256SUMSOK means your download is exactly what was published.
Project layout
BitTwin/
├── run.sh # portable run (self-test + start)
├── install.sh # per-user install / uninstall
├── bittwin/
│ ├── core/ # sync engine, no GUI code
│ │ ├── fs_local.py # local disks & drives
│ │ ├── fs_sftp.py # SFTP backend (Paramiko), host-key checks
│ │ ├── planner.py # mirror / update / two-way decisions
│ │ ├── executor.py # verified copy → fsync → read-back → atomic rename
│ │ ├── baseline.py # two-way sync history
│ │ └── session.py # compare() and synchronize()
│ └── gui/ # PyQt6 interface
├── assets/ # icon, desktop entry
├── docs/ # screenshots
├── tools/make-release.sh # builds a release archive + SHA256SUMS
├── tests/ # engine, SFTP, security and GUI tests (built-in test SFTP server)
├── .github/workflows/ # CI (tests on Ubuntu 24.04 + 26.04, Bandit, ShellCheck) and CodeQL
└── SECURITY.md # how to report a vulnerability
Run the tests any time with:
python3 -m unittest discover -s tests -vLicense
GNU GPL v3.0 © narl3yyy-svg
