Introduction
This is the documentation of irsync 0.1.0-beta.7.
irsync is a one-way directory synchroniser in the mould of rsync, rebuilt for
today’s networks. It runs on both ends of a transfer and connects through
iroh, so two machines find each other and traverse
NATs and firewalls without port forwarding, dynamic DNS or SSH tunnels. The
daemon side is reached by its iroh identity, not by an address.
It is designed to fill whatever bandwidth the link has, and to survive a bad one. A sync session outlives any single network connection: when hotel wifi drops, the laptop sleeps or the process is killed, the next run of the same command resumes where it stopped; when the interrupted run had finished listing and no deletion is asked for, it does so without re-walking and re-comparing the whole tree. Many files are in flight at once, scanning runs alongside the transfer, and a persistent index makes repeat runs over a large, mostly unchanged tree cheap.
Correctness comes first. How we verify irsync’s correctness states what a completed sync promises, and how you can check it yourself.
Beta. irsync is beta software. The command line and the network protocol may still change before the first stable release, and versions may then not talk to each other. Keep another copy of anything you sync with it.
Install
Pick one way. Every package contains both irsync and fileset.
The install script puts both in ~/.local/bin and the man pages in
~/.local/share/man:
curl --proto '=https' --tlsv1.2 -LsSf https://irsync.org/install.sh | sh
It installs the newest stable release. To try a beta, add --beta straight
after sh -s --. --alpha takes the newest release of any kind:
curl --proto '=https' --tlsv1.2 -LsSf https://irsync.org/install.sh | sh -s -- --beta
The first stable release will be v0.1.0. Until it is out, add --beta.
The script checks the installer’s signature before it runs it, with irsync
or minisign if either is installed.
If neither is, it warns and goes on. Add --require-signature (next to
--beta, before any other argument) to make it stop instead. Releases before
v0.1.0-beta.5 have no signatures, so the script never installs them.
Then man irsync, man fileset and man irsync.toml work. The script
never edits your shell startup files. If ~/.local/bin is not on your
PATH, it says how to add it; on Linux, logging out and in again is
usually enough. To remove what it installed (your config
and state stay), run it with --uninstall. Drop --beta here too once
v0.1.0 is out:
curl --proto '=https' --tlsv1.2 -LsSf https://irsync.org/install.sh | sh -s -- --beta --uninstall
The Homebrew, apt and dnf packages install the man pages too. cargo install installs none.
Homebrew (Linux and macOS), from v0.1.0 on:
brew install irsync-dev/tap/irsync
Debian, Ubuntu, Fedora and RHEL, from v0.1.0 on: the apt and dnf setup commands are on dist.irsync.org.
You can also download a tarball from the GitHub Releases page.
For anything else, build from source with Rust’s cargo. You need Rust 1.96
or newer. If you have no Rust yet, or an older one, get it from
rustup.rs first. The build takes a few minutes.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # only if you have no Rust
cargo install --git https://github.com/irsync-dev/irsync irsync
Release binaries cover Linux on x86_64 and arm64, and macOS on Apple Silicon. Other Linux and macOS machines can build from source. All of these are supported, as client and as daemon.
With ssh, the client is enough: irsync pair installs irsync, fileset and
the manual pages on the server. A released irsync downloads the release files
for the server’s platform on this machine, whatever that platform is. If the
download fails and the server has the same OS and CPU, it sends this machine’s
own files instead. The server needs no internet access. A build from source
sends only its own files, so it can set up only a server with the same OS and
CPU. For another server, and for a platform with no release files (an Intel
Mac, for example), install irsync on both machines and set the server up by
hand (Your first sync).
Quick start
If ssh myserver logs you in to the server, irsync needs to be installed on
the client only. Set the server up once, then push to any path your account
there can reach:
irsync pair myserver
irsync -av ~/Photos/ myserver:/srv/photos/
irsync pair sets the server up over ssh: it installs irsync there, grants
this client access to any path (all_paths = "rw"), starts the daemon as a user
service and saves myserver as a server. It is the only command that uses
ssh. Syncs connect over iroh.
To share only named directories instead, set the server up by hand: export a directory, grant the client access to it and start the daemon. Your first sync walks through both ways.
Who this book is for
People who copy large directory trees between a client and a server, both machines they control, and who want a transfer to finish after the network has failed along the way. If you know rsync, you know most of the command line: irsync accepts many of rsync’s flags, some with a different meaning, and adds its own; the command-line reference lists them, and Known limitations lists the rsync options it does not have.
How the book is organised
The pages come in four kinds, and each kind answers a different question.
- Tutorial. One guided run from nothing to a first transfer, for someone who has not used irsync before.
- How-to guides. Short recipes for a task you already have in mind: troubleshooting a first sync, pairing with a server over ssh, running the daemon, changing exports, choosing a connection path, cleaning up, measuring a transfer.
- Reference. Every flag, command, configuration key, file and metric, and the wire protocol, stated as the code has it.
- Explanation. Why irsync behaves as it does: how we verify its correctness, sessions and resume, identity and trust, connections, and the transfer algorithm.
A separate part, fileset, covers a companion tool that checks with code of its own, not irsync’s. It checks a copy against a recorded manifest, whichever tool made the copy, and finds bitrot. Start at Introduction to fileset.
A last part, Contributing, is for people who work on irsync itself: setting up a checkout, running the tests, the stress and network-stress tools, and how this website is built.
The source is at github.com/irsync-dev/irsync.
Get help
- A first sync fails. Troubleshoot a first sync goes through the common causes and their fixes.
- Questions and bugs. Ask a question or report a bug in
GitHub Issues. For a bug,
say which version runs on each machine (
irsync --version), which OS, the command you ran and what it printed. - Security problems. Do not open a public issue. Email security@irsync.org instead; the security policy says what to include.
License
irsync, and the tools in its repository, are MIT licensed; see the LICENSE file.
Your first sync
In this tutorial you push a photo library from a client to a server, resume an interrupted push, and pull the library back. First the quick way, over ssh; then the same setup by hand, for when ssh is not available or you want to share only named directories.
You need irsync on the client (see Install).
The quick way installs it on the server for you; for the setup by hand,
install it on the server too.
The client runs irsync. The server runs irsync daemon, the daemon,
which serves its directories. The two machines find each other by the
daemon’s identity, an EndpointId, not by an address: you need no port
forwarding, dynamic DNS or SSH tunnel.
You write no configuration file by hand. Each machine generates its key the
first time a command needs it and says so on stderr:
irsync: generated identity <path>.
The quick way: over ssh
If ssh myserver already logs you in to the server, one command on the
client sets it up, and then you can push:
irsync pair myserver
irsync -av ~/Photos/ myserver:/srv/photos/
irsync pair is the only command that uses ssh. It takes myserver as an
ssh destination and sets the server up. A sync never uses ssh. The account you
log in to must not be root: irsync refuses to set up a daemon as root.
pair says what it did:
irsync: pairing with myserver over ssh
irsync: set up myserver over ssh:
irsync: installed irsync 0.1.0 (1a2b3c4) in ~/.local/bin, with fileset and the manual pages
irsync: generated the daemon identity
irsync: granted this client (myclient, a3e4753e5e) access to any path
irsync: started the daemon
irsync: the daemon runs as a systemd user service (irsync.service), also after a reboot
irsync: saved server myserver -> 4a29f16a4f
irsync: paired with myserver; syncs go over iroh, not ssh
In steps, it:
- installs irsync on the server, the same way
install.shdoes:irsync,filesetand the manual pages go to~/.local/binand~/.local/share/man. The client sends the files; the installer script places them. A released irsync downloads the release files of its own version on the client, for any server platform, and checks them. If that download fails and the server has the same OS and CPU, it installs this machine’s own files instead. The download needscurlorwget, andtar, on the client; the server needs no internet access. A build from source has no release to download, so it works only when the server has the same OS and CPU. Not every platform has a release (an Intel Mac has none). Otherwise irsync stops and says so; install irsync on both machines and set the server up by hand. Add--no-ssh-installto copy nothing and use the irsync already at~/.local/bin/irsyncthere. The installer never edits your shell startup files. When the server’s login shell does not findirsync, the installer prints the line to add to a startup file there, and you see it whilepairruns; - lets this client reach any path your account on the server can, read-write
(
all_paths = "rw", see Rights on a client). The server saves the client under its host name, heremyclient, as a[clients.myclient]entry, so its grants show that name instead of a long id. The first push to/srv/photosmakes it an export, granted to this client only; - starts the daemon and makes it a user service: a systemd service on Linux,
a launchd agent on macOS. It keeps running and starts again after a reboot.
On a Mac that happens once someone logs in there. Pass
--no-serviceto start it in the background only, until the next reboot; - saves
myserveras a server on the client, with the daemon’sEndpointIdandssh = "myserver". Formike@myserveror an IP address, see which names pair saves.
If the server has no systemd or launchd user session, or the service file
there is not one irsync wrote, pair starts the daemon in the background
and prints the steps to make it a service yourself (see
Run the daemon).
The push runs over iroh. -a recurses into directories and keeps
symlinks, permissions, times, group, owner and device files; -v lists each
file. The trailing / on ~/Photos/ copies the directory’s contents, as in
rsync. Add -P to see a live block at the bottom of the screen that shows
the transfer as it runs.
Syncs use the saved server and never touch ssh. If the daemon has stopped, a sync
waits 15 seconds for an answer, then stops and says
myserver did not answer. It names what to check on the server. To start the
daemon again, run irsync pair myserver. A sync to a name irsync does not
know stops too, and tells you to run irsync pair.
Pair with a server over ssh covers the options: pairing
again after you update irsync, keeping the daemon out of the public DHT with
--server-no-dht, another ssh command with --rsh, and limiting the client to
named exports.
Run it again
irsync -av ~/Photos/ myserver:/srv/photos/
Nothing has changed, so nothing is sent.
Interrupt a transfer and resume it
Add a few large files to ~/Photos, start the push, and press Ctrl-C while
it runs. Then run the same command again:
irsync -av ~/Photos/ myserver:/srv/photos/
irsync finds the stopped session and says resuming session <id> from <time>. Files that were partly sent continue where they stopped.
The same happens after a dropped network connection, except that irsync
redials on its own, for up to 24 hours by default.
Pull the library back
Pull it into a new directory on the client:
irsync -av myserver:/srv/photos/ ~/Photos-copy/
A pull is the same command with the remote side first. To see what a pull would fetch without writing anything, give the remote side alone:
irsync myserver:/srv/photos/
That is the whole quick way. The rest of this tutorial sets a server up by hand. It shows what the quick way does for you.
Set the server up by hand
Here you export two directories under names, grant the client access to them, and start the daemon yourself. Nothing goes through ssh. irsync must be installed on both machines.
This part is an alternative to the quick way, not a next step. Follow it on a
server that was not set up over ssh: on one that was, a daemon is already
running, so step 4 would start a second one, and step 5 would replace the
myserver server that the quick way saved.
1. Find the client’s EndpointId
On the client, print its identity:
irsync id show
Under the client: label, the first line is the public key in OpenSSH form,
the second the client’s EndpointId, 64 hexadecimal characters:
client:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKPkdT5ep05k50XpxNELD9dR2+AwSddC6w6lRciXA9+6 irsync
a3e4753e5ea74e64e745e9c4d10b0fd751dbe03049d742eb0ea545c89703dfba
If the client already has an ssh key at ~/.ssh/id_ed25519, irsync uses it
instead of generating one, and reads it without changing it.
Copy the last line. You paste it on the server in step 3.
2. Export two directories on the server
On the server, create the directories and export them under a name:
sudo mkdir -p /srv/photos /backup
sudo chown "$USER" /srv/photos /backup
irsync export add photos:/srv/photos
irsync export add backup:/backup
irsync export add writes ~/.config/irsync/irsync.toml and prints the
daemon’s EndpointId on stdout. Copy it. You paste it on the client in
step 5.
This is the ID clients connect to. irsync id show --daemon prints it again
later. Plain irsync id show on the server prints the server’s client
identity, which is a different key: nothing answers to it, so a client given
that one waits, then gives up with a message that points at
irsync id show --daemon
(see Troubleshoot a first sync).
3. Grant the client access
Still on the server, give the client’s EndpointId a readable name, as a client, and grant
it both exports. Replace <client-id> with the line you copied in step 1:
irsync client add myclient <client-id>
irsync grant add photos myclient
irsync grant add backup myclient
Each grant add gives read-write access. The daemon refuses every key that no
grant names, before it reads any request.
4. Start the daemon
Start the daemon in the foreground, in a terminal you leave open:
irsync daemon
It prints a banner, its EndpointId and the sockets it listens on, then logs
warnings to stderr:
irsync daemon 0.1.0-beta.1 (a1b2c3d) started
relay: default (n0)
discovery: dns, dht, mdns
endpoint id: 4a29f16a4f80a3fd171ef5573c106dbda470ec24f5a97933752746b567ab9aff
listening on: 192.168.1.10:41235
The daemon publishes its addresses so that a client holding its EndpointId
can find it. Leave it running for the rest of the tutorial.
5. Name the server on the client
On the client, give the server’s EndpointId the name myserver. Replace
<server-id> with the line you copied in step 2:
irsync server add myserver <server-id>
The client now pins this EndpointId for myserver. If anything else
answers, the connection fails; there is no trust-on-first-use prompt.
6. See what the server shares
Ask the daemon what this client may reach:
irsync myserver:
The daemon answers with one line per export, its name, its real path and your access:
backup /backup rw
photos /srv/photos rw
7. Push the library
Copy the contents of ~/Photos into the photos export:
irsync -av ~/Photos/ myserver:photos/
Resuming and pulling work as in the quick way, with myserver:photos/ in
place of myserver:/srv/photos/.
8. Push by real path
You can also name a path on the server directly. The path must lie inside an
export that the client has a grant for, here backup:
irsync -av ~/Documents/ myserver:/backup/myclient/Documents/
A path outside every export the client may use is refused as “no access”, whether it exists or not.
What you did
irsync pairset the server up over ssh and saved a server; every sync after that went over iroh.- By hand, you copied two
EndpointIds, one in each direction: the client’s to the server, the daemon’s to the client. That exchange is the whole of the trust setup. - You pushed, resumed, listed and pulled with rsync’s flags and its trailing-slash rule.
The name is optional: the raw EndpointId works in its place, as in
irsync -av ~/Photos/ <server-id>:photos/, and irsync grant add photos <client-id> works without client add.
Next steps
- Troubleshoot a first sync: what the usual first-run errors mean.
- Pair with a server over ssh: the options of the quick way.
- Command line: every flag.
- Remote addresses: how the daemon
resolves
myserver:photos,myserver:Picturesandmyserver:/backup. - Management commands:
server,client,export,grant,idandconfig. - Seed the index: when the server already
holds a copy that
irsyncdid not make. - Run the daemon: under systemd or launchd, as its own account.
To check that the copy arrived intact, see Verify an irsync transfer.
Troubleshoot a first sync
The errors people meet on a first sync, what they mean and what to do.
A host added by hand never answers
The sync waits, then stops with one of two messages. When no address was ever published for the ID, which is the usual case for a wrong one:
irsync: ~/Photos: gave up after 5 attempts: the daemon never answered: connecting to 4a29f16a4f80a3fd171ef5573c106dbda470ec24f5a97933752746b567ab9aff: no address found for it. Is this the daemon's EndpointId? On the server, `irsync id show --daemon` prints it (plain `irsync id show` prints the client's). Also check that the daemon is running there.
When an address is known but nothing answers there, for example a daemon that has stopped:
irsync: ~/Photos: gave up after 5 attempts: the daemon never answered: connecting to 4a29f16a4f80a3fd171ef5573c106dbda470ec24f5a97933752746b567ab9aff: timed out; if you added this server's ID by hand, it must be the daemon's EndpointId: on the server, irsync id show --daemon prints it (plain irsync id show prints the client's). Also check that the daemon is running there
The listing, irsync myserver:, ends with the same advice.
Cause. Most often the client was given the server’s client ID instead
of its daemon’s. A server has two keys: plain irsync id show prints the one
it uses as a client; clients must connect to the daemon’s. Nothing answers to
the wrong one, so the client can only wait. The other cause is a daemon that
is not running.
Fix. On the server, print the daemon’s ID:
irsync id show --daemon
On the client, save it under the server’s name, replacing the old one:
irsync server add myserver <daemon-id>
Then check that irsync daemon is running on the server.
A server paired with irsync pair did not answer
The sync’s error ends like this, after what it tried:
irsync: ...; myserver did not answer. On myserver, check that the daemon is running: systemctl --user status irsync (Linux) or launchctl list org.irsync.daemon (macOS). Its log: journalctl --user -u irsync for a systemd service, else ~/.local/state/irsync/daemon.log. To start it again from here: irsync pair myserver
Cause. The daemon is not running or cannot be reached. A sync never uses ssh, so it cannot start the daemon for you.
Fix. Do what the message says. On the server, check the service. Its log is
in journalctl --user -u irsync when a systemd service runs the daemon, and
in ~/.local/state/irsync/daemon.log for the launchd agent on macOS and when
pair started it in the background.
A background daemon does not survive a reboot. To start the daemon again from
the client, run:
irsync pair myserver
On a Mac, the agent starts after a reboot only once someone logs in there.
A sync names a server irsync does not know
irsync: myserver is not a saved server or an EndpointId (saved servers are in ~/.config/irsync/irsync.toml). To set it up over ssh: irsync pair myserver. To add it by hand: irsync server add myserver <daemon-id>
Cause. A sync, push, pull or listing never uses ssh, so it does not set a
server up. myserver is not in your saved servers, or it was mistyped.
Fix. Check the spelling. If the name is right and ssh myserver works, run
irsync pair myserver. Otherwise add the server by hand, as in
Your first sync. A name
saved as a client only gets a similar message: this machine has never dialled
its daemon, so run irsync pair for it.
pair could not reach the daemon over iroh
irsync pair: myserver is set up and saved, but this machine could not reach its daemon over iroh within 30 s. The daemon there is running (home relay https://euc1-1.relay.n0.iroh.link./; direct addresses 192.168.1.5:41641), but the lookups have not found it yet; a daemon that has just started can take a minute to be found. Run `irsync pair myserver` again to check once more; it keeps what was set up.
Cause. The server is set up and its daemon runs, but this machine cannot
find it the way a sync looks for it. Right after the daemon started, the
lookups may not know it yet, above all when only the DHT looks it up
(--no-dns, or dns = false on this machine). Or something between the two machines
blocks iroh: a firewall that drops UDP, or no route to a relay. When the
message says the daemon reported no relay and no direct address, the
daemon itself is not on the network: read the log it names.
Fix. Wait a minute and run irsync pair myserver again. It sets nothing
up twice and only checks once more. If it still fails, see
Connect directly or through a relay. To check one path,
pass it to the check: irsync pair --address 192.168.1.5:41641 myserver
dials that address only.
pair stops: the server runs another OS or CPU
irsync: pairing with myserver over ssh
irsync: pairing with myserver over ssh failed: myserver runs linux aarch64, this irsync is macos aarch64 and a development build (0.1.0-beta.1 (1a2b3c4, dirty)). Only release builds install on another OS or CPU. Install irsync on both machines and set the server up by hand: https://irsync.org/book/tutorial/first-sync#set-the-server-up-by-hand
Cause. When the server’s OS or CPU differs from the client’s, irsync pair
installs the release binary of the client’s own version. That needs a
client that is itself a release: a build from source has no matching release
binary. The same stop, worded “there is no release binary for that
platform”, comes for a server no release is built for, such as an Intel Mac.
Fix. Use a released irsync on the client
(Install), or install irsync on the server
yourself and
set the server up by hand.
Installing it on the server does not make pair work, unless you run
with --no-ssh-install: pair otherwise uses its own copy of the client’s
exact build.
Other messages from this step:
need curl or wget on this machine to download the release binary, ortar failed (it must be able to read .xz): the client downloads and unpacks the release itself. Install the missing tool on the client.could not download …: the client could not reach GitHub. Check the network and run again.GitHub answered with an error for …: either GitHub is having trouble (run again later), or there is no release with the client’s version number, which means the client is a development build. Then use a released irsync.release v… is not this build: the client is a development build that carries a release’s version number. Use a released irsync.the release binary for … does not run on myserver: the server could not run the binary, for example because its home directory is mountednoexec. Install irsync on the server yourself and set it up by hand.the download of … is damaged (SHA-256 does not match): run again.the release … has no signature for sha256.sum, or GitHub answered with an error: run again later, in case GitHub had a problem. If the message stays, or it isthe release … failed the signature check, the release on GitHub is not signed the way this irsync expects, so it refuses to use it. Report it on GitHub Issues, and set the server up by hand meanwhile. If you built irsync yourself, this is expected: only release builds install on another OS or CPU.
Nothing on the server is changed in any of these cases.
pair says there are no release files for this build
irsync: downloading irsync v0.1.0-beta.1 for macos aarch64
irsync: no release files for this build (could not download release v0.1.0-beta.1: …); installing this machine's own files
This is a notice, not an error. The server has the same OS and CPU as the
client, so when the download fails, or the release is another build,
pair sends the client’s own files instead. pair goes on. fileset and
the manual pages come along only if they sit beside the client’s irsync;
the summary says when they did not.
pair stops on the server
These stop pair after the files reached the server:
could not unpack irsync on myserver (it needs tar and a writable home directory). Nothing was changed there.: the server has notar, orpaircannot write its work directory in your home there. Installtar, or check that you own your home directory and can write to it, then run again.the installer failed on myserver; see its message above: the installer script ran on the server and stopped. Its own message, printed just before, says why, for example a~/.local/binyou cannot write to. Fix that and run again.
pair stops: –no-ssh-install
irsync: pairing with myserver over ssh failed: --no-ssh-install: myserver has no irsync 0.1.0-beta.1 (ae5ebe5) at ~/.local/bin/irsync (found none). Install that version there, or run without --no-ssh-install (or set ssh_install = true in the config). Nothing was changed.
Cause. With --no-ssh-install, or ssh_install = false in the config file,
pair copies nothing. It needs the client’s exact build at
~/.local/bin/irsync on the server, and found another version there
(found irsync …) or none.
Fix. Install the same version as the client on the server, in
~/.local/bin. Or let pair install it: run without --no-ssh-install, and
remove ssh_install = false from the config file if it is there.
The daemon rejected this client’s key
irsync: the daemon rejected this client's key: no access to myserver:photos/. On the daemon's machine, irsync grant list a3e4753e5ea74e64e745e9c4d10b0fd751dbe03049d742eb0ea545c89703dfba shows what this key may reach; irsync grant add EXPORT a3e4753e5ea74e64e745e9c4d10b0fd751dbe03049d742eb0ea545c89703dfba grants an export, irsync export add NAME:PATH exports a directory (irsync id show prints this id)
Cause. The daemon answered, but no grant lets this client reach that path: the client was never granted an export, the path lies outside every export it may use, or a grant was removed.
Fix. On the server, grant the export to the client’s ID, which the message names:
irsync grant add photos <client-id>
irsync pair does not fix this. Pairing again never changes the grants a client has lost. The refusal
is on purpose, and irsync never adds back an all_paths you removed. See
Identity and trust.
The transfer is slow and says relay
The live block (--progress), and the summary line at the end of each session (-vv), name the
path the connection took: direct or relay. See
Connect directly or through a relay.
Cause. The two machines could not reach each other directly (hole punching failed, often when both sit behind strict NATs), so the data goes through a relay server. Relays are a fallback and much slower than a direct path.
Fix. Connections explains when hole punching fails. When the connection has to stay on a relay, run your own relay close to both machines.
Run the daemon
irsync daemon runs in the foreground and never puts itself in the
background. Let a service manager start it, restart it and collect its logs:
systemd on Linux, launchd on macOS. Its flags are in
Command line.
What it prints
Once startup can no longer fail, the daemon prints these lines on stdout, and prints them again after every reload:
endpoint id: <EndpointId>
listening on: <socket>
debug port: <socket>
When stdout is a terminal, a short banner comes first (version, relay and discovery); it is not printed to a pipe or a file.
There is one listening on: line per bound socket. The debug port: line
appears only when debug_addr is set (see Telemetry). A
process that starts the daemon can read these lines and dial at once.
Run it as its own account
A daemon that the service manager runs as its own account, here irsync,
keeps everything in one directory: /etc/irsync/ on Linux,
/usr/local/etc/irsync/ on macOS. There is no /etc lookup, so the daemon
gets --config explicitly.
-
Create the account’s directory, owned by the account:
install -d -o irsync -g irsync -m 0755 /etc/irsyncThe management commands replace a file by writing a new one next to it and renaming it, so the directory must be writable by
irsync. -
Write
/etc/irsync/irsync.tomlwith the state directory and the daemon’s key. Without these two keys both would default to paths under the account’s home directory:state_dir = "/var/lib/irsync" [daemon] identity = "/etc/irsync/daemon_ed25519" -
Manage the exports as the daemon’s account, with the same
--configthe daemon gets. For the nouns the flag may stand anywhere after the noun:sudo -u irsync irsync export add photos:/srv/photos --config /etc/irsync/irsync.toml sudo -u irsync irsync client add myclient <id> --config /etc/irsync/irsync.toml sudo -u irsync irsync grant add photos myclient --config /etc/irsync/irsync.toml sudo -u irsync irsync config set daemon.listen 0.0.0.0:4433 --config /etc/irsync/irsync.toml sudo -u irsync irsync id show --daemon --config /etc/irsync/irsync.toml sudo -u irsync irsync show --config /etc/irsync/irsync.tomlThe first
export addgenerates the daemon’s key and prints itsEndpointId.
Without --config, a management command edits your own
~/.config/irsync/irsync.toml: irsync export add would write your file,
generate a stray ~/.config/irsync/daemon_ed25519 and print that key’s id as
the daemon’s. Running the commands as irsync also keeps the files owned by
the account that reads them; a daemon key generated by root has mode 0600 and
the daemon cannot read it. Root can run the same commands with the same flags
if it fixes the ownership afterwards.
irsync show and irsync id show -a also load the client key that
[defaults] identity names in the same file, and generate it if it is missing.
Do not run it as root
A daemon that receives a push applies the metadata the client sends: permissions, owner, group, device nodes. As root, that lets any client with write access to an export create setuid files owned by root, files owned by other users, and device nodes in it. Run the daemon as an unprivileged account that owns the export trees. Ownership is then applied only where that account may change it, to its own groups, as rsync does without privilege.
The daemon enforces this: started as root, it prints why and exits. It has
not had a security audit, so running it as root must be your own choice. To
make that choice, start it with --run-as-root-i-know-what-i-am-doing, or
set allow_root = true under [daemon] in its config file. It then logs a
warning at every start.
irsync pair (see Your first sync) never
starts a daemon as root. When the ssh account is root it stops before it
installs or changes anything, whatever the server’s config says. Use another
account, or set the daemon up by hand as described above.
Run the daemon as a user service
irsync pair makes the daemon a user service, so it keeps running and starts
again after a reboot. It writes one of these files, each marked
Written by irsync pair:
- On Linux,
~/.config/systemd/user/irsync.service.pairalso turns onloginctl enable-linger, so the service runs when you are not logged in. - On macOS,
~/Library/LaunchAgents/org.irsync.daemon.plist, a launchd agent. After a reboot it starts only once someone logs in on the Mac.
The file runs irsync daemon -vv --config with the full paths of the
binary and of the server’s config file, so the service finds the same
config as pair did.
irsync never changes a service file it did not write. If such a file starts
daemon with the same irsync binary that pair installed (as the one in
the steps below does), pair uses it as it is. If it starts anything else,
pair leaves it alone, starts the daemon in the background instead, and
prints the steps below. It does the same on a server with no systemd or
launchd user session. irsync pair --no-service, which you pass for a
daemon you run your own way, also starts it in the background. A background
daemon runs under your account until the server reboots. Nothing starts it
again: run irsync pair myserver from the client when it has stopped.
Where the daemon writes its log depends on how it runs. As a systemd service,
its output goes to the service manager: journalctl --user -u irsync. The
launchd agent on macOS, and a daemon that pair started in the background,
write ~/.local/state/irsync/daemon.log.
To make the service yourself, the steps are these.
On Linux, put this in ~/.config/systemd/user/irsync.service:
[Unit]
Description=irsync daemon
[Service]
ExecStart=%h/.local/bin/irsync daemon -vv
Restart=on-failure
[Install]
WantedBy=default.target
Then stop the daemon irsync started and let the service take over:
pid="$(sed -n 's/^pid=//p' ~/.local/state/irsync/daemon.lock)"
kill "$pid"
while kill -0 "$pid" 2>/dev/null; do sleep 0.2; done
systemctl --user enable --now irsync
loginctl enable-linger $USER
loginctl enable-linger lets your user services run when you are not logged
in.
On macOS, put this in ~/Library/LaunchAgents/org.irsync.daemon.plist, with
your home directory for $HOME:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>org.irsync.daemon</string>
<key>ProgramArguments</key><array><string>$HOME/.local/bin/irsync</string><string>daemon</string><string>-vv</string></array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
</dict></plist>
Then stop the daemon irsync started and let the service take over:
pid="$(sed -n 's/^pid=//p' ~/.local/state/irsync/daemon.lock)"
kill "$pid"
while kill -0 "$pid" 2>/dev/null; do sleep 0.2; done
launchctl load -w ~/Library/LaunchAgents/org.irsync.daemon.plist
If the state directory is not the default one, pair prints the path of
daemon.lock to use instead. The kill is needed because the lock lets only
one daemon run at a time: the service cannot start while the first daemon
holds it, so the loop waits until that daemon has exited. These lines are sh
syntax; from fish or tcsh, run them under sh.
Under systemd
-
Write
/etc/systemd/system/irsync.service:[Unit] Description=irsync daemon After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/local/bin/irsync daemon -vv --config /etc/irsync/irsync.toml ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=5 User=irsync [Install] WantedBy=multi-user.targetThe
User=account needs read access to the export paths, write access to the read-write ones, read access to the key and toirsync.toml, and write access tostate_dir. -
Start it, and start it at boot:
systemctl enable --now irsync -
Follow its log:
journalctl -u irsync -f
systemctl reload irsync applies changed [daemon] settings without a
restart.
Under launchd
-
Write
~/Library/LaunchAgents/org.irsync.daemon.plist:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.irsync.daemon</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/irsync</string> <string>daemon</string> <string>-vv</string> <string>--config</string> <string>/usr/local/etc/irsync/irsync.toml</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>StandardErrorPath</key> <string>/usr/local/var/log/irsync.log</string> </dict> </plist>For a daemon that runs as its own account, put the file in
/Library/LaunchDaemonsinstead, add aUserNamekey naming the account, and manage the exports as in Run it as its own account, with the/usr/local/etc/irsync/paths. -
Load it:
launchctl load ~/Library/LaunchAgents/org.irsync.daemon.plist
launchd has no reload verb. To apply changed [daemon] settings without a
restart, send the signal yourself:
kill -HUP $(pgrep -f 'irsync daemon')
Durability
A push writes each file to a temporary name and renames it into place. By
default, as in rsync, nothing is flushed to disk explicitly: a power loss or
kernel crash in the seconds after a push can leave a file at its name with
the right size and time but not its content, which the next quick check does
not notice. A client asks for a flush per file with --fsync; an export
with fsync = true (irsync config set exports.NAME.fsync true) flushes
every push into it whatever the client asked. On a slow disk this costs
time: about 30% of a push of 31,000 small files to btrfs on two spinning
disks. Like read_only, the setting is read on every connection.
Logs
The daemon logs to stderr; journald and launchd’s StandardErrorPath capture
it. The default level is warn: the daemon logs warnings and errors only.
-vv gives info logs, which is what a service wants in its journal; -vvv
gives debug, -vvvv trace, and -vvvvv trace plus every protocol message,
as on the client. -q lowers it to errors only. RUST_LOG overrides all of
them, in the tracing filter syntax, for example RUST_LOG=irsync=debug.
Each line of a session carries the session’s span and its fields, as in
session{session_id=… side="daemon" …}:transfer: …, which tells concurrent
sessions apart.
Stop it
SIGTERM or SIGINT (Ctrl-C) stops the daemon cleanly: it closes its endpoint
and flushes its telemetry. SIGTERM is what systemctl stop and launchd send
to stop a job. A session cut off this way resumes like any dropped
connection. SIGHUP does not stop the daemon; it
reloads the settings.
See also
- Change exports and settings
- Files and state: what the daemon reads and writes.
- Configuration: the
[daemon]keys.
Pair with a server over ssh
When ssh myserver logs you in to the server, irsync pair myserver sets
the server up: it installs irsync there, grants this client access, starts
the daemon and saves myserver as a server.
Your first sync walks
through it. This page covers the options.
pair is the only command that uses ssh. A sync, push, pull or listing
never does: it dials the daemon over iroh. A sync to a name irsync does not
know stops and tells you to run irsync pair.
The connection check
Last, pair dials the new daemon over iroh, the way a sync will: by the
lookups, with no help from the ssh session. It asks the daemon for the
exports this client may use, so the check also shows that the grant works:
irsync: checking that myserver answers over iroh
irsync: myserver answers over iroh
irsync: paired with myserver; syncs go over iroh, not ssh
A daemon that has just started is usually found within seconds. When it is
looked up in the DHT only, it can take a few seconds more. pair keeps
trying for up to 30 seconds. If the daemon cannot be found by then, pair
fails. The server stays set up and saved: run the same irsync pair again
to check once more. See
Troubleshooting.
The check takes the connection flags of a sync, such as --relay,
--no-dht and --address, and the server’s and [defaults] settings.
The flags are used for the check only, not saved.
The names pair saves
On the client, the server name depends on the host you gave irsync pair:
| You typed | Saved server name |
|---|---|
myserver | myserver |
mike@myserver | mike@myserver, and also myserver when no server has that name yet |
192.168.1.5 or mike@192.168.1.5 | the server’s own host name, for example myserver |
[fe80::1] (an IPv6 address goes in brackets) | the server’s own host name |
Every server keeps what you typed as its ssh value, so pairing again
logs in the same way.
- With
mike@myserver, both names reach the same daemon. Ifmyserveris a server already, it is left as it is: the first one wins. - For an address, irsync asks the server for its host name and uses the part
before the first
.. If that name already belongs to another daemon, the name ismyserver-2, thenmyserver-3. - A server that gives no usable name (none, or
localhost) keeps an IPv4 address as its name. An IPv6 address cannot be a server name, sopairstops before it changes anything; give the server a host name or add the server by hand.
Typing the address again finds the saved server by its ssh value, and
irsync pair says so:
irsync: 192.168.1.5 is saved as myserver
A server that is already saved with a name to reach it by, such as
ssh = "mike@myserver", keeps that name when you type its address: an
address can go stale. The address is saved beside it, in ssh_aliases, so
typing it again finds the same server. The same goes for a second spelling of
an address, such as u@192.168.1.5 after 192.168.1.5.
It checks the daemon saved under that name, wherever it is now. If the
address has since gone to another machine, that is not the machine you get.
First take the address off the old entry (irsync server remove myserver, or
change its ssh or ssh_aliases value in the config file), then run
irsync pair with the address again: the new machine is set up and saved
under its own name. Do not pair again before that: it would point the old
name at the new machine.
On the server, pair saves the client under the client’s short host name
as a client, and gives it the all_paths and admin rights:
[clients.myclient]
client_id = "a3e4753e5ea74e64e745e9c4d10b0fd751dbe03049d742eb0ea545c89703dfba"
all_paths = "rw"
admin = "rw"
The admin right lets this client change the server later with
irsync remote.
The name is a label. The daemon decides access by the EndpointId the name
stands for, never by what a client calls itself. A client the server already
has a name for keeps that name.
The two machines can sync in both directions under the same names. The server
may have a [servers.myclient] entry for the same machine: a server and a
client may share a name, and neither touches the other. When the server later
runs irsync ... myclient:PATH before it has paired with myclient, the
sync stops: myclient is saved as a client only, and this machine has never
dialled its daemon. Run irsync pair myclient on the server. It sets the
daemon up over ssh and saves the daemon’s endpoint_id as
[servers.myclient].
pair stops, and leaves the server’s configuration and daemon as they
were, when the client’s host name cannot be used there. The server checks
the name with the irsync that pair has just installed or updated
there; that install stays, and the message says so. The cases:
- The name already belongs to another client. This also happens when the
same machine comes back with a new key, for example after a reinstall.
The message names the entry and the command to run on the server if that
client is gone:
irsync client remove myclient -f. Else rename the client machine. - Grants on the server still name
myclient, and no[clients.myclient]says who that is. Those are left from a removed client, or they name a server. They are not handed to a new client of the same name. Take the name out of the lists the message names. - The client has no usable host name of its own (none, or
localhost). Give the machine a host name.
Pair again
Run pair again on purpose, for example to update irsync on the server
after you updated the client, or to start a daemon that has stopped:
irsync pair myserver
For a saved server it runs the same setup again. It never adds back an
all_paths you removed on the server.
A sync never does this for you. When the daemon does not answer within
15 seconds, the sync stops and says myserver did not answer. It names what
to check on the server and the command to start the daemon again:
irsync pair myserver. The sync dials only once, unless you pass
--dial-retries N or set dial_retries in the server’s table or in
[defaults]: then it tries N more times first. A daemon that answers but refuses the client is
“fixed” by no one: that refusal is on purpose, and the sync stops with the
“rejected this client’s key” message.
Keep the daemon out of the public DHT
The daemon publishes its addresses in the mainline DHT, so syncs find it
even when its IP address changes. To keep it out of that public
table, pass --server-no-dht:
irsync pair --server-no-dht myserver
pair then writes dht = false under [daemon] on the server.
The daemon can still be found through DNS and the relay.
Use another ssh command
Use --rsh or IRSYNC_RSH for another ssh command:
irsync pair --rsh "ssh -p 2222" myserver
ssh is used only by pair, never for the data.
Share only named directories
By default pair lets the client reach any path your account on the
server can (all_paths = "rw", see Rights on a client).
If the client should not reach every path, set this on the server before you
pair:
irsync config set daemon.allow_all_paths false
The daemon then ignores all_paths, and you grant exports by hand as in
Your first sync.
What gets installed, and from where
pair installs the same files as install.sh: irsync and fileset in
~/.local/bin, and the three manual pages under ~/.local/share/man. It
runs the installer script on files the client sends. The installer never
edits your shell startup files. When the server’s login shell does not find
irsync, pair shows the line to add.
A released irsync downloads the release files of its own version on the client, for every server platform, and checks their SHA-256:
irsync: downloading irsync v0.1.0-beta.1 for linux aarch64
irsync: set up myserver over ssh:
irsync: installed irsync 0.1.0-beta.1 (ae5ebe5) in ~/.local/bin, with fileset and the manual pages (release files for linux aarch64)
If the download fails and the server has the same OS and CPU, irsync says so
and installs this machine’s own files instead. Then fileset and the manual
pages come along only if they sit beside this machine’s irsync:
irsync: installed irsync 0.1.0-beta.1 (ae5ebe5) in ~/.local/bin (no fileset, no manual pages: this machine has none beside its irsync)
The download happens on the client, which needs curl or wget, and a
tar that reads .xz. The client also checks that an irsync release key
signed the release’s list of SHA-256 sums for exactly this version. The
server needs no internet access, but it needs tar to unpack the files it
is sent, and a home directory you can write to. Either way the server runs
the new binary with --version before it replaces anything, and keeps what
it had unless the binary reports the client’s exact build.
Release files exist for Linux on x86_64 and arm64 and for macOS on Apple
Silicon. For any other server, and for a client built from source whose
server has another OS or CPU, pair stops and changes nothing. Then
install irsync on the server yourself and
set the server up by hand.
Installing it on the server does not make pair work, unless you run
with --no-ssh-install: pair otherwise uses its own copy of the client’s
exact build. See
Troubleshooting
for the messages.
To copy nothing to the server, use --no-ssh-install (or ssh_install = false
in the config file). pair then uses the irsync at ~/.local/bin/irsync
there, and stops if it is missing or another version.
Keep the daemon running
pair makes the daemon a user service, so it starts again after a reboot.
Pass --no-service to skip that. See
Run the daemon.
Change exports and settings
A running daemon picks up most changes without a restart. Exports, grants and
clients apply from the next connection. The [daemon] settings apply when you
send it SIGHUP. Only a few settings wait for the next start.
Run the commands on the daemon’s machine, as the daemon’s account and with the
daemon’s --config (see Run the daemon).
Exports, grants and clients
Edit them with the management commands, or by hand:
irsync export add music:/srv/music
irsync grant add music myclient
irsync grant remove photos phone
Nothing else is needed. The daemon reads irsync.toml afresh on every
accepted connection, once the handshake has proved the peer’s EndpointId. It takes the clients, exports
and grants from that read.
- A
grant removeorexport removedoes not end a session already in progress. It refuses new connections only. - If the file cannot be read or parsed, in any table, the daemon logs the
error at
warnwith the file and the line, rejects that connection and keeps running. It does not fall back to an earlier copy. A missing file counts as empty. - A daemon with no exports starts, logs a warning naming the config file, and serves nothing until an export exists.
At startup, by contrast, a file that does not parse stops the daemon. The management commands check the file before they write it, so an edit made with them never leaves it unparsable; an edit by hand can.
When a client is refused
The daemon refuses a client in one of two ways:
- A key that no grant names is closed on before the daemon reads any request.
- A key with grants that asks for a path outside what it may use is refused
with
no access to PATH. The answer is the same whether the path is outside every export or missing.
Either way the client says that the daemon rejected its key for that address,
and prints its own EndpointId with what to run on the daemon’s machine:
irsync grant list <id>
irsync grant add EXPORT <id>
irsync export add NAME:PATH
irsync grant list <id> shows what the key may reach. The daemon’s log shows
rejecting unauthorized key or rejecting session, with the first ten hex
digits of the client’s EndpointId.
How a path finds its export, and why a grant on an outer export reaches the exports inside it, is in Remote addresses.
Reload the daemon settings
-
Change a
[daemon]key:irsync config set daemon.idle_timeout 1h -
Send the daemon SIGHUP:
kill -HUP <pid>Under the systemd unit from Run the daemon,
systemctl reload irsyncdoes the same.
The daemon re-reads the config file and applies listen, relay,
dht, dns, mdns, congestion, pq_key_exchange, portmap,
identity, idle_timeout, dormant_session_timeout and
max_dormant_sessions_per_key:
- It binds a new endpoint with the new network settings and prints
endpoint id:andlistening on:again. - Sessions in progress finish on the connection they started on. A client that dials an address the daemon has given up is refused.
idle_timeoutapplies to the sessions accepted from then on.- A
--listengiven on the command line stays in force over the file’slisten. - A changed
identityis applied and logged atwarn, since clients need the newEndpointId.
A reload that cannot be applied, because the file does not parse, a port
cannot be bound or the key cannot be read, is logged at warn, and the daemon
keeps running as it was.
What waits for a restart
| Change | When it applies |
|---|---|
state_dir | At the next start. A reload logs that it changed. |
debug_addr | At the next start. A reload logs that it changed. |
[telemetry] | At the next start. A reload logs that it changed. |
index_at_start on an export the daemon has already opened | At the next start. |
| Removing an export | At once for new connections; the export’s index stays open, and its hourly collection keeps running, until the next start. |
The daemon opens an export’s index, and starts its hourly collection and the
hashing index_at_start asks for, the first time the export is used: at startup for the
exports already in the file, and at the first connection naming an export
added later. Exports with the same path share one index.
See also
- Configuration: every
[daemon]key. - Seed the index:
index_at_startandirsync index --export.
Manage a server from your client
irsync remote changes a server’s exports, clients and grants from your
own machine, without ssh. It uses the same connection a sync does.
Give a client the right
On the server, give the client admin:
irsync client set myclient admin=rw
A client paired with irsync pair already has it: pair sets
admin = "rw" together with all_paths = "rw".
There are two levels:
admin = "rw"reads, and changes exports, clients and grants.admin = "ro"reads only. It lets the client runlist,show,config getandconfig list, and nothing that changes the server.config getandconfig listshow every setting in the server’s config file, such as itsstate_dir, the ids and addresses of the servers it has saved, and its[defaults]settings. None of them is a secret.
admin = "rw" is the whole account, like all_paths = "rw": a client that
can add an export and grant itself access to it can reach any path. Give it
only to machines you trust that far. See the
threat model.
The server must run the same irsync version as the client. An older server
answers myserver runs an older irsync: update it there.
Run a command
Name the server first, then the command. myserver is a saved server (see
Pair with a server over ssh) or the daemon’s EndpointId.
irsync remote myserver export add 'photos:~/Photos'
irsync remote myserver grant add photos myclient
irsync remote myserver show
Quote a home path, as in 'photos:~/Photos'. Without the quotes your own
shell turns ~ into your home directory here, and the server would get the
wrong path. irsync remote notices a path that starts with your own home
and stops before it connects, with the command to use instead.
The commands that work remotely:
| Command | Needs |
|---|---|
export list, export add, export remove | ro to list, rw to change |
grant list, grant add, grant remove | ro to list, rw to change |
client list, client add, client remove, client rename, client set | ro to list, rw to change |
show | ro |
config get KEY, config list | ro |
They take the same arguments as on the server; see
Management commands. Not remote: config set,
config unset, export set, export rename, id, server and
index --export. Do those on the
server.
The server answers each command. The lines it prints may name the server’s own config path.
What a change does
Each call is one change. The server applies it all or not at all, while it
holds the config lock. If it fails, the config file is as it was, and the
error says why. When another command is editing the file, the server waits up
to 2 seconds and then answers busy. Run the command again.
A client cannot remove its own admin right, or lower it to ro, from afar.
Do that on the server. This keeps you from locking yourself out by mistake.
Reads answer from the saved config file. The last change wins: there is no check that someone else did not change the same thing a moment ago.
What the server logs
The server logs each change at info, with the client’s name. A refused
attempt, such as a client with no admin right or a change that fails, is
logged at warn, with the name. Reads are not logged.
A client without admin gets only not allowed. It learns nothing about the
server.
The text trace (-vvvvv) and the capture file show the admin messages, on
both sides, like any other. A capture of an admin session holds the config
contents it carries: export paths, client names and ids. It holds no secrets.
See Trace and capture the protocol.
See also
Connect directly or through a relay
By default a client finds the daemon by its EndpointId, connects through a
relay and moves to a direct path when hole punching succeeds. This page shows
how to see which path a sync took, and how to change that: refuse relays, use
your own relay, turn the lookups off, or dial a known address. Why it works
this way is in Connections.
See which path a sync took
Run the sync with -vv:
irsync -avv ~/Photos/ myserver:photos/
The first line of the summary at the end of each session names the path,
direct or relay:
session 1/1 push ~/Photos/ -> myserver:photos/ wall 3:12 direct
The live progress block (--progress) shows the same word while the sync runs.
Refuse relays
A sync that cannot get a direct path then fails instead of running through a relay.
-
For one sync, on the client:
irsync -a --relay disabled ~/Photos/ myserver:photos/ -
For every sync to one server, or to every server:
irsync server add myserver <id> --relay disabled irsync config set defaults.relay disabled -
On the daemon, which then neither uses a relay nor is reachable through one:
irsync config set daemon.relay disabled
The lookups stay on. A daemon’s DNS and DHT records carry only its relay
address, though, so a client that refuses relays finds the daemon through mDNS
on the local network, or through an address you give it
(below). A daemon with relays off and dht on logs a
warning at start, since its DHT records would be empty.
Use your own relay
Clients and daemons behind a symmetric NAT on both ends cannot hole-punch and
stay on the relay. A relay of your own, near the daemon, serves them better
than the shared public relays. iroh ships one as iroh-relay.
-
Run
iroh-relayon a host both sides can reach. -
Point the daemon at it, then reload:
irsync config set daemon.relay https://relay.example.net -
Point the client at it, for one server or for all:
irsync server add myserver <id> --relay https://relay.example.net irsync config set defaults.relay https://relay.example.netFor one sync,
--relay URLdoes the same.
Turn the lookups off
-
On the client,
--no-dht,--no-dnsand--no-mdnsskip a lookup for one sync. A server’sdht,dnsandmdnskeys, or[defaults]’s, turn a lookup off for good:irsync server add myserver <id> --dht no --mdns no irsync config set defaults.dns false -
On the daemon, the same three keys in
[daemon]say where it publishes its addresses:irsync config set daemon.dht false irsync config set daemon.mdns false -
For a server paired over ssh,
irsync pair --server-no-dhtsets the daemon’sdht = falsefor you (see Your first sync).
Dial a known address
Two irsync processes on one machine, on one LAN, or anywhere without
internet access need no relay and no lookup. listen alone only pins the
sockets; it does not isolate the daemon. Turn everything off explicitly.
-
On the daemon, in
irsync.toml:[daemon] listen = ["127.0.0.1:0"] # at most one IPv4 and one IPv6 entry; port 0 = daemon picks relay = "disabled" portmap = false # no UPnP/PCP/NAT-PMP gateway probing dht = false dns = false mdns = false--listen ADDRon the command line replaces thelistenlist. -
Start the daemon and read its address from stdout:
endpoint id: <id> listening on: 127.0.0.1:43210 -
On the client, dial that address, for one sync or for good:
irsync -a --address localhost:43210 ./src <id>:data/ irsync server add local <id> --address 127.0.0.1:43210The second command writes this table:
[servers.local] endpoint_id = "<id>" address = ["127.0.0.1:43210"]
--address takes ip:port, [ipv6]:port or host:port, may be repeated,
and resolves host names with the system resolver. With an address the client
turns its relay, DNS, DHT, mDNS and port mapper off. The daemon’s
EndpointId is still required and still checked. --address together with
--relay is refused.
Keep to one path
An address picks where the connection starts. Once connected, the two sides still tell each other their local addresses, and iroh may open more paths between them and move the transfer to the fastest one: a LAN path instead of the VPN you dialled, say. Neither irsync nor iroh can turn that exchange off, but each side offers only the addresses its sockets are bound to:
- The client, given an address, binds to the local address the system sends from to reach it, one for IPv4 and one for IPv6, taken from the first given address of each. It offers the daemon nothing else. If that local address goes away, say when a VPN drops, the sync fails and redials instead of moving to another network. Addresses of one IP version share that local address, so a second address that needs another one may not be reachable.
- The daemon offers every address it listens on.
listenwith a specific address, as in step 1, offers only that one. Withoutlisten, or with0.0.0.0or[::], it offers each of its interfaces, and the client opens paths to them as well.
With both, the connection keeps to the path you dialled.
See also
- Configuration: the
relay,address,dht,dnsandmdnskeys. - Command line:
--relay,--no-dht,--no-dns,--no-mdns,--address.
Seed the index
Use this when a destination already holds a copy of the data that irsync
did not make: an earlier rsync, a restore from backup, a disk you copied by
hand. Seeding hashes those files into the destination’s index first, so that
the first session reuses their content for renamed and copied files instead
of fetching it over the network.
irsync keeps one index per root under state_dir (see
Configuration). The index
only knows files that irsync has hashed: files it placed, files it updated,
and files read by a -c run. Without seeding, a session still finds some
reuse on its own: before it fetches a whole file of 64 KiB or more, it hashes
up to four destination files of exactly that size that the index does not
know yet. Seeding covers the rest.
Seeding never makes a wrong decision. Content taken from a local file is verified like any other, and an index row that has gone stale falls back to a fetch.
On the client, before a pull
Index the directory that the pull writes into. For
irsync -a myserver:photos/ ~/Photos/ that is ~/Photos; for
irsync -a myserver:photos ~/ it is ~/photos.
-
See how much would be read:
irsync index -n ~/PhotosIt prints one line per root:
ROOT: N file(s), M to hash (B bytes). -
Hash the files:
irsync index ~/PhotosFiles whose index row is still fresh (same size, modification time, change time, device and inode) are skipped, so running it again costs only the walk.
You can name several roots in one command. If a file cannot be read or a
directory cannot be listed, irsync index reports it, carries on, and exits
with code 23.
On the daemon, before a push
Run these on the daemon’s machine, as the account the daemon runs as and with
the same --config, so that they write to the daemon’s state_dir.
-
Hash one export, or every export:
irsync index --export photos irsync index --export all--exportmay be given more than once, and beside local roots.-ncounts what would be hashed. The daemon uses the new rows from its next session on. -
Or let the daemon hash an export every time it starts, which suits an export whose files change outside
irsync:irsync config set exports.photos.index_at_start trueFor a new export,
irsync export add photos:/srv/photos --index-at-startdoes the same. The daemon hashes the export in the background when it starts, or at the first connection for an export added while it runs, and logsexport indexedwhen done.
See also
- Clean up state: how index entries of deleted files are removed.
- Command line: the flags of
irsync index.
Clean up state
An interrupted transfer leaves state behind on purpose, so that the next run
can resume: partial files beside their destinations (or under
--partial-dir), and a dormant session in the index under state_dir.
Garbage collection removes what nobody is coming back for. It also forgets the
index entries of files that are gone or were replaced.
Most of the time you need not do anything: the client and the daemon collect
on their own. Run irsync gc when you want the space back now, or after you
stopped syncing a directory for good.
What runs on its own
- The client, at the start of each sync that is not a dry run, collects under that sync’s local root. It walks the root at most once a day, or sooner once a partial-file record has gone an hour without being touched. It removes partial files and sessions older than 7 days.
- The daemon checks each export once an hour, starting a minute after the
export’s index is opened. It walks an export at most once a day, unless
partial-file records have become collectable since the last walk. It removes
partial files and sessions older than
dormant_session_timeout, 7 days by default (see Configuration). Each walk logs a summary atinfo. A file it cannot remove is logged and reported, and the walk carries on. - The daemon also drops a client key’s oldest dormant sessions as soon as
the key has more than
max_dormant_sessions_per_keyof them in an export, 25 by default. Their partial files stay until the hourly check removes them.
A partial file is kept as long as a stored session still plans to write it.
An export that holds another export (such as a whole home exported
automatically) leaves that inner export’s tree to its own collection; irsync gc does the same for indexes whose roots lie inside one another.
Collect by hand
-
See what would go:
irsync gc -nIt lists every partial file it would remove, then a summary line:
N part file(s), N session(s), N index entries would be removed. -
Remove it:
irsync gc
irsync gc visits every root that has an index under state_dir: each local
directory this account has synced or indexed, and the exports of a daemon that
runs in this account with the same config. For each root it removes partial
files and dormant sessions older than 7 days, and the index entries of regular
files that are gone or were replaced by another file. It also removes the
index files an older irsync left behind, unless a process still has one
open. Use --config PATH when
the state_dir you mean is set in another config file.
An entry under a directory that could not be read is kept, since the file may only be unreadable. A walk that finds no file at all removes no entries, since the root may be a mount point whose file system is not mounted.
Uninstall irsync
If you installed with the install script, run it again with --uninstall.
Until v0.1.0 is out, the channel flag --beta has to come first:
curl --proto '=https' --tlsv1.2 -LsSf https://irsync.org/install.sh | sh -s -- --beta --uninstall
It removes these files, and says so for each one it finds:
~/.local/bin/irsyncand~/.local/bin/fileset~/.local/share/man/man1/irsync.1and~/.local/share/man/man1/fileset.1~/.local/share/man/man5/irsync.toml.5
It leaves the directories, your config (~/.config/irsync) and your state
(~/.local/state/irsync by default, or wherever state_dir points).
Delete those by hand when you want them gone. If you installed with
Homebrew, apt or dnf, remove irsync with that tool instead.
See also
- Seed the index
- Command line: the flags of
irsync gc.
Watch a transfer with telemetry
When a sync is slow, irsync can show where the time went (walking, hashing,
waiting on the peer, writing, deleting) and what it cost in CPU, memory, disk
I/O and bytes on the wire. One set of spans and metrics feeds three sinks,
each off until you turn it on. The names and labels are listed in
Metrics.
| Sink | Turn it on | What you get |
|---|---|---|
| Summary | -vv on the client | A block at the end of each session: wall time, busy time per activity, time waiting on the peer, CPU, peak memory, bytes on the wire, RTT and loss. |
| Debug HTTP port | --debug-addr [IP:]PORT on the client; debug_addr under [daemon] for the daemon | /metrics in the Prometheus text format, /debug/timing with wall and busy time per span name, and /debug/flame with folded stacks. |
| OpenTelemetry | OTEL_EXPORTER_OTLP_ENDPOINT, or otlp_endpoint under [telemetry] | Spans and metrics over OTLP. |
With all three off the cost is a few untaken branches; the measurements are in Metrics.
Read the summary
Add -vv to the client:
irsync -avv ~/Photos/ myserver:photos/
At the end of each session it prints a block like this one:
session 1/2 push ./photos -> nas:/backup wall 3:12 direct, 1 reconnect
busy walk 21.0s hash 9.3s ×4.0 read 1:02 send 1:48 delete 1.3s
waiting peer 44.0s index 0.7s ×3.0
transfer 1,882 files 3.41G literal 12.00G matched 17.77M/s
hashing 2,107 files 15.30G 412.00M/s
disk read 15.40G write 0 fsync 0.0s
network sent 3.52G recv 41.00M rtt 12ms (max 40ms) lost 0.02%
process cpu 1:12 user, 0:31 sys peak rss 312.00M peak fds 214
After direct or relay, the first line names the connection’s key
exchange, as in direct, X25519MLKEM768. X25519MLKEM768 is the hybrid
that also holds against a quantum computer; X25519 means the other side
does not offer it. See
Networking.
busy and waiting show the wall time during which each activity ran,
followed by ×N when on average N tasks, 1.5 or more, ran it at once. waiting peer is time this side
had nothing to do. What each activity covers is in
Busy time and peer wait.
Open the debug port
-
On the client, add
--debug-addrwith a port, orIP:PORT; a bare port binds127.0.0.1:irsync -a --debug-addr 9464 ~/Photos/ myserver:photos/After the sync the client prints
irsync: debug port open at ADDR; Ctrl-C to exitand keeps the port open until SIGINT or SIGHUP, so that you can fetch the final numbers.--debug-port-no-waitcloses the port when the sync ends instead.On the daemon, set
debug_addrand restart the daemon:irsync config set daemon.debug_addr 127.0.0.1:9464The daemon prints
debug port: ADDRat start and keeps the port open as long as it runs. If the port cannot be bound, it logs a warning and runs without it. -
Fetch what you need:
curl -s localhost:9464/metrics curl -s localhost:9464/debug/timing curl -s localhost:9464/debug/flame
The port speaks plain, unauthenticated HTTP. Keep it on loopback or behind a firewall.
Draw a flamegraph
/debug/flame serves the self time of each span stack in microseconds, in the
folded form that the inferno tools read. It keeps up to 10,000 distinct
stacks and adds the rest up under [other].
-
Install
inferno:cargo install inferno -
Run the sync with
--debug-addr 9464. When it finishes, while the client waits for Ctrl-C, render the graph:curl -s localhost:9464/debug/flame | inferno-flamegraph > f.svg
The stacks are irsync’s own spans, so the graph shows time per phase and per
file, not per function.
Trace single files
Per-file spans, file and its children, are off by default, because a tree
of tens of thousands of files would swamp a trace. Set IRSYNC_TRACE_FILES=1
to send them to the span sinks: OTLP, /debug/timing and /debug/flame.
IRSYNC_TRACE_FILES=1 irsync -a --debug-addr 9464 ~/Photos/ myserver:photos/
Set it on the daemon’s side to get the daemon’s per-file spans.
Export over OpenTelemetry
-
Point
irsyncat a collector, with the environment or in the config file:export OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 irsync config set telemetry.otlp_endpoint http://127.0.0.1:4318[telemetry]applies to the client and the daemon alike. The daemon reads it at start. -
Run a sync. The client’s
sessionspan starts a trace. The client sends its W3C trace context to the daemon, whosesessionspan joins it as a child when the daemon exports too, so one sync is one trace across both machines.
Export is on when OTEL_EXPORTER_OTLP_ENDPOINT,
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT or OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
is set, or otlp_endpoint is in the config file; the environment wins. The
protocol is OTEL_EXPORTER_OTLP_PROTOCOL (grpc or http/protobuf), else
otlp_protocol (grpc or http), else HTTP.
The other standard OTEL_* variables are honoured: headers, timeouts, the
sampler, OTEL_SERVICE_NAME (by default irsync for the client and
irsync-daemon for the daemon), OTEL_RESOURCE_ATTRIBUTES and
OTEL_METRIC_EXPORT_INTERVAL. Metrics are exported every 10 seconds, unless
OTEL_METRIC_EXPORT_INTERVAL says otherwise, and once more at exit. An empty
OTEL_METRIC_EXPORT_INTERVAL counts as unset. The exit
flush takes at most 2 seconds.
The daemon samples every session unless OTEL_TRACES_SAMPLER is set on its
side: the sampled flag in the client’s trace context does not suppress the
daemon’s spans, which then join the client’s trace id even when the client
dropped its own. The client keeps the SDK’s default sampler, which follows the
parent and is otherwise always on.
Export needs the cargo feature otel, which is on by default. A build
without it warns and ignores the OTLP settings.
Local collector
The repository has a Docker Compose setup with an OpenTelemetry collector,
Jaeger and Prometheus:
compose.yaml,
collector.yaml
and
prometheus.yml.
-
In a clone of the repository, start it:
docker compose -f docs/telemetry/compose.yaml up -dThe collector listens on 4317 (gRPC) and 4318 (HTTP). Jaeger’s UI is on http://localhost:16686, Prometheus on http://localhost:9090. Prometheus scrapes
host.docker.internal:9464every 5 seconds. -
Run a sync that exports over OTLP and opens the debug port on 9464:
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 \ irsync -a --debug-addr 9464 src/ HOST:export/ -
Look at the results. Jaeger shows the
sessiontrace. Prometheus has the metrics from the debug port. The metrics sent over OTLP go to the collector’sdebugexporter, in its log. -
Stop it:
docker compose -f docs/telemetry/compose.yaml down
See also
- Metrics: every metric, label and span.
- Configuration: the
[telemetry]keys.
Verify a download
Every irsync release is built by GitHub Actions from a tagged commit. GitHub signs a record of that build, called an attestation: which file, which commit, which workflow. You can check any file you downloaded against it. Doing so shows that the file was built by irsync’s own release workflow, and not swapped somewhere on the way to you.
Every file on a release is also signed with irsync’s release key. The key is kept offline, away from GitHub, so a signature is the stronger proof. The minisign check below is the simplest, and needs no GitHub account.
The attestation checks need the GitHub CLI
(gh), logged in with gh auth login.
Check the signature with minisign
Install minisign 0.10 or newer
(apt install minisign, dnf install minisign, brew install minisign).
Download the file and its signature, which has the same name with
.minisig added, from the
releases page. Then:
minisign -Vm irsync-x86_64-unknown-linux-musl.tar.xz -P RWR6ngoFwyY7D9i4MAL2T4n1UkGwrCdSGA/SMowtANaffYWkTZdrAtAZ
-P is irsync’s public key, the line above. It is the same key as in the
README and in
packaging/signing/release-keys.pub in the repository.
A good file prints Signature and comment signature verified, and a line
Trusted comment: irsync vX.Y.Z. Check that the trusted comment names the
version you downloaded. Otherwise someone could give you an older release’s
signed files. A failure means: don’t use the file, and please
report it.
The same works for every file on the release, the checksum files included.
Releases from before signing started have no .minisig files; use the
checks below for them.
Check the signature with irsync
An installed irsync can check a download too, with the release keys built in:
irsync verify-signature --trusted-comment "irsync vX.Y.Z" irsync-x86_64-unknown-linux-musl.tar.xz
The signature file, .minisig added to the name, must be next to the file.
Exit status 0 means a good signature, 1 a bad or missing one. This command is
hidden from irsync --help.
The install script
install.sh checks the signature of the installer it downloads, using irsync
(if the installed one has verify-signature) or minisign. It stops without
running anything if the check fails. After a good check it says so, with
the signature’s trusted comment:
irsync: good signature on irsync-installer.sh (checked with minisign), trusted comment: irsync v0.1.0-beta.5
With neither tool it warns; add --require-signature to make it fail
instead. If you run irsync-installer.sh straight from the release page,
nothing checks its signature. Check it yourself as above.
An archive or the installer
Download the file from the releases page, then:
gh attestation verify irsync-x86_64-unknown-linux-musl.tar.xz \
--repo irsync-dev/irsync \
--signer-workflow irsync-dev/irsync/.github/workflows/release.yml
--signer-workflow matters: without it, a file attested by any workflow in
the repository would pass, including one someone pushed on a branch. A good
file prints Verification succeeded! and the commit it was built from. That commit
is the one the release tag points to. The release workflow runs on a
temporary branch, pinned/vX.Y.Z, which is deleted afterwards, so the
attestation names that branch and not the tag. Don’t use
--source-ref refs/tags/vX.Y.Z: it will not match. A
failure means: don’t use the file, and please
report it.
The same works for every other file on the release: the other archives,
irsync-installer.sh, irsync.rb and the checksum files. Releases up to
v0.1.0-beta.2 have attestations for the archives only.
A .deb or .rpm package
The packages live in the apt and dnf repository at dist.irsync.org, not on the GitHub release. apt and dnf already check every download against the repository’s signing key. To check a package file by hand as well:
gh attestation verify irsync_1.2.3_amd64.deb \
--repo irsync-dev/irsync \
--signer-workflow irsync-dev/irsync/.github/workflows/packages.yml
The apt and dnf signing key
apt and dnf trust whatever key you imported. Check its fingerprint once, when you add the repository:
curl --proto '=https' --tlsv1.2 -fsSL https://dist.irsync.org/irsync.asc | gpg --show-keys
Compare the 40-character fingerprint it prints with the one in SECURITY.md. The two must match exactly.
If irsync’s signing key ever changes its subkey, apt and dnf need the key
file again: download irsync.gpg (apt) or irsync.asc (dnf) as when you
added the repository. The fingerprint stays the same.
Homebrew
The formula in irsync-dev/tap pins the SHA-256 of each archive, and
brew refuses a download that doesn’t match. To check the archive itself,
find it in Homebrew’s cache and verify it as above:
gh attestation verify "$(brew --cache irsync)" \
--repo irsync-dev/irsync \
--signer-workflow irsync-dev/irsync/.github/workflows/release.yml
Command line
irsync sync [OPTIONS] SRC... DEST
irsync list [OPTIONS] HOST[:PATH]
irsync COMMAND ...
irsync [OPTIONS] SRC... DEST # the same as irsync sync
irsync [OPTIONS] HOST:[PATH] # the same as irsync list
irsync copies directory trees from one machine to another, in one
direction, in the mould of rsync. It runs on both ends: the client runs
irsync, and the server runs irsync daemon, the daemon, which serves its
directories. A push copies from the client to the server, a pull the other
way. If you can log in to the server with ssh, irsync pair sets the server
up for you (see irsync pair).
The terms used on this page:
- iroh is the network library
irsyncconnects through. With it, two machines find each other and get through NATs and firewalls without port forwarding, dynamic DNS or ssh tunnels. - An
EndpointIdis the public half of a machine’s key, printed as 64 hexadecimal digits. The client and the daemon each have one. A client reaches a daemon by itsEndpointId, not by an address. A server entry in the config file gives a daemon’sEndpointIda name, such asmyserver. - A relay is a server both sides can reach. A connection starts through a relay and moves to a direct path when it can. The relay passes on encrypted packets that it cannot read. n0 runs public relays, which are the default.
- An export is a directory the daemon shares under a name.
- A grant lets a client use an export, read-write or read-only. The daemon refuses every key that has no grant and none of the rights below.
- The
all_pathsright lets a client reach any path the daemon’s account can, read-write or read-only. The daemon then makes an export for each new path the client uses.all_exportsreaches every export you made by hand, andadminlets the client manage the server from afar. All three are set withirsync client set.
The last two lines of the synopsis above are the rsync-style shorthand: the
flags irsync shares with rsync are spelled the same, so a common rsync
command often works with irsync in its place. Not every rsync flag is
there: -z, --partial and -e are among those missing, and both ends
must run irsync. See Known limitations. The named forms
irsync sync and irsync list do the same and cannot be mistaken for a
command that a later irsync adds, which makes them the safer choice in
scripts.
irsync --help (or -h) lists irsync’s flags, each with what it does;
irsync COMMAND --help lists a subcommand’s.
Examples
Set up a server you can log in to with ssh myserver, then push the contents
of ~/Photos:
irsync pair myserver
irsync -av ~/Photos/ myserver:/srv/photos/
pair is the only step that uses ssh. Later runs of the push go over iroh and
send only what changed.
Pull the copy back into a new directory:
irsync -av myserver:/srv/photos/ ~/Photos-copy/
List the exports this client may reach, then the files a pull would fetch:
irsync myserver:
irsync myserver:/srv/photos/
irsync list myserver and irsync list myserver:/srv/photos/ do the same.
Push again and delete on the server what is gone from the source. Run it
with -n first to see what would change:
irsync -avn --delete ~/Photos/ myserver:/srv/photos/
irsync -av --delete ~/Photos/ myserver:/srv/photos/
Operands
Each operand is a local path or HOST:PATH. HOST is a server name from the
configuration or an EndpointId; PATH is resolved
on the daemon’s machine, as described in
Remote addresses. A HOST that is neither is an error that
names irsync pair; see irsync pair.
- A
:before the first/makes an operand remote, as in rsync. To name a local file whose name has a colon, write./name:with:colons. - Exactly one side is remote. A push (local to remote) may have several sources; each one runs as its own session, one after the other. A pull has one source.
- rsync’s trailing-slash rule holds on both sides:
Photos/copies the directory’s contents,Photoscopies the directory itself. - A source may be one file, pushed or pulled. It is placed as rsync would
place it: into
Tif that is a directory, asTif it does not exist, overTif that is a file. See Copying one file. - A single remote operand lists instead of copying, as
irsync listdoes; there the colon may be left out (irsync list HOST).irsync HOST:prints the exports this client may reach, oneNAME PATH ACCESSline each, whereACCESSisrworrowith the export’sread_onlyapplied.irsync HOST:PATHprints the files a pull would fetch (just that file, ifPATHis a file) and writes nothing; it recurses unless--no-recursiveis given. A listing does not redial: if the connection fails, it exits instead of waiting out the reconnect window.irsync HOST:retries a server that has not answered yet as a pull does (--dial-retries). It takes the flags that say how to reach the server (--relay,--pq-key-exchange,--no-dht,--no-dns,--no-mdns,--address,--dial-retries,--idle-timeout), the filters and--no-recursive. A sync’s other flags, such as-aor--delete, are refused.
The daemon honours the client’s flags in both directions, filters included.
irsync pair
irsync pair [OPTIONS] HOST
pair sets a server up over ssh. It is the only command that uses ssh: a
sync, push, pull or listing never does. HOST is an ssh destination, such as
myserver or me@myserver, or a saved server name. pair then:
- installs
irsync,filesetand the manual pages on the server (the same files asinstall.sh, in~/.local/bin) when the server has no matching build; - gives this client
all_paths = "rw", access to any path, andadmin = "rw", the right to manage the server remotely; - starts the daemon and makes it a user service: a systemd service on Linux, a launchd agent on macOS;
- saves
HOSTas a server withssh = "HOST".
It prints what it did and ends with paired with myserver; syncs go over iroh, not ssh. The account you log in to must not be root.
A release build downloads the release files on this machine, for every server platform. If that fails and the server has the same OS and CPU, it installs this machine’s own files instead. The server needs no internet access.
On Linux the service is ~/.config/systemd/user/irsync.service, and pair
turns on linger so that it runs when you are logged out. On macOS it is
~/Library/LaunchAgents/org.irsync.daemon.plist, which starts after a reboot
only once someone logs in on the Mac. A service file that irsync did not write
is left alone. With no service manager, a foreign service file or
--no-service, the daemon runs in the background until the server reboots and
pair prints the steps to make a service yourself. See
Run the daemon.
For a saved server, pair checks it again: it updates irsync, starts the
daemon if it has stopped and updates the server’s endpoint_id if it
changed. It never adds back all_paths removed on the server. A sync
to a server pair saved dials once and waits at most 15 seconds for the
daemon to answer. It retries only when dial_retries is set, by
--dial-retries N, in the server’s table or in [defaults]: then it tries N
more times first. When the daemon does not
answer, the sync stops and names irsync pair as the way to start it again.
See Your first sync.
Last, pair checks that the daemon can be reached over iroh. It dials the
daemon the way a sync will, by the lookups (or by --address), and asks for
the exports this client may use. It tries for up to 30 seconds. When the
daemon cannot be found in that time, pair fails with what the server said
about where its daemon can be reached; the server stays set up and saved, and
running the same irsync pair again checks once more. A daemon that answers
but refuses the client fails pair at once.
| Flag | Meaning |
|---|---|
--rsh CMD | The remote shell, split on spaces like rsync’s -e, for example --rsh "ssh -p 2222". Default: IRSYNC_RSH, else ssh. |
--no-ssh-install | Copy nothing to the server: use the irsync already at ~/.local/bin/irsync there, and stop if it is missing or another version. Default: ssh_install in the config file, else install. |
--server-no-dht | Turn the server’s DHT publishing off ([daemon] dht = false); a running daemon re-reads its settings. Without it the server’s setting is left alone, and new servers publish. |
--no-service | Do not make the daemon a user service: start it in the background, until the server reboots. For a daemon you run your own way. |
--relay, --no-dht, --no-dns, --no-mdns, --address ADDR, --pq-key-exchange, --dial-retries N, --idle-timeout DUR | How the check at the end reaches the daemon, as for a sync. They are not saved. --no-dht is about this machine’s lookups; --server-no-dht about the server’s publishing. |
rsync-compatible flags
These have rsync’s spelling and meaning. Flags with rsync’s spelling and a different meaning have a section of their own: rsync spelling, different meaning.
| Flag | Meaning |
|---|---|
-a, --archive | Archive mode, the same as -rlptgoD. |
-r, --recursive | Recurse into directories (implied by -a). Without recursion only the top-level entries are transferred, and directories are skipped. |
--no-recursive | Turn off the recursion that -a implies. Also spelled --no-r. |
-d, --dirs | Without recursion, transfer directories without their contents. |
-l, --links | Copy symlinks as symlinks. Without it they are skipped. |
-p, --perms | Preserve permissions. |
-t, --times | Preserve modification times. |
-g, --group | Preserve the group, where the receiving user may set it. |
-o, --owner | Preserve the owner, only when the receiving side runs as root. |
-D | The same as --devices --specials. |
--devices | Preserve character and block device nodes. |
--specials | Preserve FIFOs. Sockets are never copied. |
-H, --hard-links | Files linked together in the source are linked together in the destination. |
-v, --verbose | List each file transferred, and end with rsync’s sent … received … and total size is … lines. -vv adds a summary of time, CPU, memory and bytes at the end of each session, and info logs; -vvv debug logs, -vvvv trace logs, -vvvvv also every protocol message (see Trace and capture the protocol). |
-q, --quiet | Print errors only. Also turns the live progress block off. |
-n, --dry-run | Change nothing on either side. With -v or -i, list what would be done. |
-c, --checksum | Compare by content, not by size and time: every file on both sides is read, no cached hash is trusted, and the index is refreshed from what was read. |
-u, --update | Skip files that are newer on the destination. |
--delete-before | Delete before the transfer, once both sides are listed. |
--delete-during | Delete each directory’s extraneous entries as the run leaves that directory, so space is freed as the run goes. |
--delete-after | Delete after the transfer; what --delete does. Only one of --delete-before, --delete-during and --delete-after may be given. |
--max-delete N | Stop deleting after N removals. The run exits with code 25. |
--exclude PATTERN | Exclude paths that match an rsync pattern: *, **, ?, [...]; a leading / anchors the pattern to the root, a trailing / matches directories only. |
--include PATTERN | Include paths that match, even if a later --exclude would hide them. |
--exclude-from FILE | Read exclude patterns from FILE, one per line. Blank lines and lines that start with # or ; are skipped. |
--include-from FILE | Read include patterns from FILE, as --exclude-from does. A pattern may be at most 4,096 bytes long; one run takes at most 16,384 rules, with at most 1 MiB of patterns together. |
--bwlimit RATE | Limit the rate at which file data is sent, on a push and on a pull. On a pull the daemon does the limiting. A bare number is KiB/s. K, M, G, T, P (also KiB to PiB) are powers of 1024, KB to PB powers of 1000, b is bytes; decimals are allowed (1.5M). 0 means no limit. |
--numeric-ids | Apply owner and group ids as sent. By default the sender’s user and group names are mapped to the receiver’s ids where they exist, as rsync does. |
--partial-dir DIR | Keep the partial files of interrupted transfers under DIR, relative to the destination root, instead of beside their files. On a pull DIR may be absolute; on a push the daemon keeps them, and only a relative DIR inside the destination is allowed. |
--inplace | Write a changed file into the destination itself instead of into a temporary file renamed over it. No second copy is needed on disk, but readers see a torn file during the transfer and a crash leaves a mixture. |
--append | Extend a destination file that is shorter than the source with the source’s tail, trusting what is already there. A destination that is not shorter is skipped. |
--append-verify | Like --append, but the existing prefix is verified too. |
--fsync | Flush each received file to disk before renaming it into place, on whichever side receives (the daemon, on a push). Off by default, as in rsync: a power loss or kernel crash in the seconds after a run can then leave a file at its name with the right size and time but not its content, which the next run’s quick check does not notice (-c does). An export’s fsync = true turns it on for every push into it. |
--paranoid | Guard against source files that change during the sync, including writers that leave the times alone (memory-mapped databases; tested on ZFS 2.4 clones only). The sending side (on a pull, the daemon) sends each file from a reflink clone where the filesystem can make one (btrfs, xfs, ZFS 2.2 and newer with block cloning, bcachefs, APFS), and otherwise hashes the file a second time before the receiver places it. At the end it checks every listed file again and sends those that changed. Files that vanished give exit 24. Cost: one clone and one delete per sent file where cloning works; an extra full read per sent file elsewhere; one stat per listed file at the end. Clones live in .irsync-clones-<uid> in a writable directory on the file’s filesystem. See Files that change during a sync. |
--ignore-errors | Run the deletion pass even when a listing was cut short by I/O errors. |
--stats | Print a block of transfer statistics at the end. |
-i, --itemize-changes | Print rsync’s per-file change summary, the itemize codes. |
-V, --version | Print the version and the commit it was built from. |
Filter rules apply in command-line order, and the first rule that matches wins.
rsync spelling, different meaning
| Flag | irsync | rsync |
|---|---|---|
--delete | Delete destination files that are gone from the source, after the transfer, the same as --delete-after. Nothing is deleted without one of the --delete flags. | The same as --delete-during. |
--delete-excluded | Also delete destination files that the filters exclude. Implies --delete, so the deletions run after the transfer. | Implies --delete, so the deletions run during the transfer. |
-S, --sparse | Leave chunks that are all zeros as holes. Without it, only files that are sparse in the source are written sparse. | Finds runs of zeros at write granularity, not only whole chunks. |
--progress | Draws the live progress block (see Output) when stdout is a terminal. | Prints the progress of each file. |
-P | The same as --progress. irsync always keeps partial files. | The same as --partial --progress. |
--info SPEC | Only progress1 and progress2 are read, as --progress; the rest is ignored. | Selects informational output, such as the progress of the whole transfer with --info=progress2. |
-h, --help | Print the flags and exit, also when other flags or operands are given. | -h is --human-readable, except on its own, where it prints the help. |
Deletions
Nothing is deleted that might merely have been unreadable. When a listing on
either side is incomplete, because a directory could not be read or an entry
could not be examined, deletions stop from that point on: --delete-before
and --delete-after then delete nothing, and --delete-during stops at the
directory where the gap was found. --ignore-errors deletes anyway. Combine
--delete with -n first to see what it would remove.
Output
As in rsync, a sync prints nothing on stdout by default. Errors and warnings
go to stderr, each failed file as it fails. -v lists each file transferred
and ends with the sent … received … and total size is … lines; -q
prints errors only.
With --progress (or -P) on a terminal, the client draws a live block at the bottom of the screen: the
listing walk on both sides, a transfer bar with rsync’s percent semantics, one
row per file that is being hashed or has a data stream open and is not yet
sent in full, and the deletion pass. The rows are as many as half the
terminal’s height allows. The files that are moving come first, fastest
first, so that progress is what you see: then files being hashed, then idle
ones, then stalled ones. A file much larger than the others (four times the
typical file in flight, at most two of them) keeps its place at the top
while it is not stalled, so you can follow it. A last line … and N more
counts the files without a row, as in … and 117 more (23 stalled) when
some of them are stalled. The transfer bar’s N in flight counts these files,
including those beyond the rows drawn. It is not the session’s window of up to
4,096 files in flight described in
Files in flight and streams:
a file in that window that is neither being hashed nor has a stream open has
no row and is not counted. On a pull the client cannot see the server’s
streams, so a file gets its row when its first data arrives; until then it
is waiting its turn, not stalled.
The transfer line shows two rates over the last 5 seconds, as in
41.20MB/s sent 380.00MB/s synced goodput 9.2×. sent is the file data
that crossed the network. synced adds the data the receiver took from
files it already had (matched data), so it is the rate at which the
destination catches up. Goodput is synced data divided by sent data for the
session: 100% means nothing was matched, and above 2 it is shown as a
ratio, so 9.2× means each byte sent put about nine in place. Once the
transfer is done, the line shows the same three numbers as averages over the
whole run. A session that ended with an error says failed there instead of
done, and its deletion pass, if it never started, reads not run. No rate is shown in a session’s first second, and both read
0B/s while the client reconnects. Matched data counts as soon as a file’s
chunks are requested, before any of its data moves, so synced jumps for a
few seconds when a large, mostly unchanged file starts. On a narrow terminal
the transfer count goes first, then goodput, then the synced rate. While the
block is drawn, failed files show in its
errors section instead of scrolling, and the full list goes to stderr once the
block is cleared at the end.
A push of several sources draws the block once per source, one after the
other. Each one starts with a line that names it, such as
session 2/3 ~/Photos -> myserver:backup: the source’s place in the run
and the two operands as typed. When a source is finished, that line and
its done lines stay on the terminal. A run with one source has no such
line.
-q turns the block off. When stdout is not a
terminal, or TERM is dumb, the block is not drawn and the output is plain
lines.
irsync flags
These have no rsync counterpart.
| Flag | Meaning |
|---|---|
--parallel N | Data streams a push keeps open at once, across all files. Default: parallel from the server entry, else from [defaults], else 128. A pull uses the daemon’s 128. See Files in flight and streams. |
--reconnect DUR | How long to keep redialling after a dropped connection, as N[s|m|h|d]. 0 gives up at once, like rsync. Default: reconnect from the server entry, else from [defaults], else 24h. This window applies only once the server has answered; before that, --dial-retries applies. |
--idle-timeout DUR | Drop a connection that moves no data and no control message for this long; the session then reconnects. DUR is written as for --reconnect; a bare number is seconds. 0 never drops one. Default: idle_timeout from [defaults], else 0. rsync’s --timeout SECS, which ends the run instead, is not accepted. |
--dial-retries N | How often to retry a server that has not answered yet, before the run gives up. The waits grow: about 1, 2, 4, 8 seconds and so on, capped at a minute. 0 gives up on the first failure. Default: dial_retries from the server entry, else from [defaults], else 4. For a server irsync pair saved (one with ssh), the default is 0 instead of 4; each try there waits at most 15 seconds. |
--relay default|disabled|URL | The relay for this sync: default for n0’s public relays, disabled for direct connections only (the address lookups stay on), or the URL of a relay of your own. Default: relay from the server entry, else from [defaults], else default. Cannot be combined with --address. |
--pq-key-exchange prefer|require | require: refuse a daemon that does not offer the post-quantum key exchange, such as an irsync built without it; nothing is sent to it. prefer: use that key exchange when the daemon offers it. Default: pq_key_exchange from the server entry, else from [defaults], else prefer. See Post-quantum key exchange. |
--no-dht | Do not look the daemon up in the mainline DHT for this run. |
--no-dns | Do not look the daemon up through n0’s DNS service for this run. |
--no-mdns | Do not look the daemon up with mDNS on the local network for this run. |
--address ADDR | Dial the daemon at ip:port, [ipv6]:port or host:port directly; repeatable. Turns the relay, DNS, DHT, mDNS and the port mapper off, and binds the client to the local address it dials from (see Keep to one path). The daemon’s EndpointId is still required and still checked. |
--config PATH | The config file. Default: ~/.config/irsync/irsync.toml. |
--identity FILE | The private key to connect with. Every command that uses the client’s key takes it; see Flags every command takes. Default: [defaults] identity in the config file, else ~/.config/irsync/id_ed25519 when it exists, else ~/.ssh/id_ed25519 when it exists, else a key generated at ~/.config/irsync/id_ed25519. A named file is the whole answer: when it is missing, a key is generated there. |
--passphrase-file PATH | Read the passphrase of an encrypted key from the first line of this file. Without it, IRSYNC_PASSPHRASE is used, else a prompt when stdin is a terminal. |
--no-resume | Start a fresh plan instead of resuming a dormant session. Partial files are still picked up. |
--no-rename-detection | Do not fill files from other files on the receiving side that hold the same content or parts of it, so a moved or copied file is transferred again. A changed file still reuses its own old version. |
--debug-addr ADDR | Serve metrics and span timings over HTTP at IP:PORT; a bare port means 127.0.0.1. The port stays open after the sync until SIGINT or SIGHUP. |
--debug-port-no-wait | With --debug-addr, close the port when the sync ends instead of waiting. |
The connection settings resolve in this order: the flag, then the server’s
table, then [defaults], then the built-in default. See
Configuration.
An on/off setting has a --no- flag here, which turns it off for this run
only: --no-dht, --no-dns, --no-mdns. irsync server add stores
such a setting instead, so its flags take a value, --dht yes or --dht no;
the value can be changed back later the same way.
Subcommands
| Command | What it does |
|---|---|
irsync sync | Copy files; the same as the rsync-style form. See Operands. |
irsync list | List a host’s exports, or the files under HOST:PATH. See Operands. |
irsync pair | Set a server up over ssh and save it as a server. See irsync pair. |
irsync remote | Manage a server’s exports, clients and grants from this client. See irsync remote. |
irsync daemon | Run the daemon. Its flags are under irsync daemon. |
irsync index | Hash the files under local roots, or of the daemon’s exports, into their index. See Seed the index. |
irsync gc | Remove abandoned partial files, dormant sessions, stale index entries and the index files of older irsync builds. See Clean up state. |
irsync server, client, export, grant, id, config, show | Manage servers, clients, exports, grants, identities and settings. See Management commands. Each of the first six alone runs its list. They take -v, -q, --config, --passphrase-file and --identity too. irsync client set NAME all_paths=rw lets a client reach any path, read-write; it is what irsync pair sets. |
irsync remote
irsync remote SERVER COMMAND
Runs a management command on a server’s daemon. SERVER is a saved server
or the daemon’s EndpointId. This client needs admin = "rw" on the server
to change things, and admin = "ro" or "rw" to read. remote dials the
server like a sync does. It never sets one up: use irsync pair for that.
COMMAND is one of export list|add|remove, grant list|add|remove,
client list|add|remove|rename|set, show, config get KEY and
config list. Each takes the arguments it takes on the server; see
Management commands. Each call sends one change,
which the server applies all or not at all. Quote a path that starts with
~: irsync remote myserver export add 'photos:~/Photos'.
The book has a how-to, “Manage a server from your client”.
Flags every command takes
-v, -q, --config PATH, --passphrase-file PATH and --identity FILE
are accepted before or after any command: irsync -v gc and irsync id show -vv both work. A
command name right after these flags is the command. So a directory called
gc is written ./gc: irsync -v ./gc host:path. The same goes for sync
and list: irsync -av ./sync myserver: pushes the directory sync.
-vasks for the command’s own extra output. Where a command has none,-vshows nothing more.-vvgives info logs,-vvvdebug,-vvvvtrace, and-vvvvvtrace plus every protocol message.-qlogs errors only and prints no summary. It wins over-v. A management command orpairthen also leaves out the lines that say what it did, such asremoved server myserver from …. What the command is run for, such as a list or an id, still prints, and so do errors and the note that a key was generated.RUST_LOGoverrides the log level.--config PATHnames the config file for every command:irsync --config f server list.--passphrase-file PATHgives the passphrase of an encrypted key to the commands that load one. The passphrase is the first line of the file; its line ending (LF or CR+LF) is not part of it, and nothing else is trimmed. Commands that load no key ignore the flag.irsync id generateuses it to write the new key encrypted. A key generated automatically is never encrypted. So the commands that would generate a missing key (a sync, a listing,id show,id list,show,export addand the daemon) fail instead. They write nothing and nameirsync id generate --passphrase-file PATH. The file must be for its owner only (chmod 600); see File permissions.--identity FILEnames the client’s key for every command that uses it: a sync, a listing,pair,remote,id show,id listandshow.irsync id generatewrites the new client key there. The daemon has a key of its own and ignores the flag.irsync show --passphrase-file PATHreads both the client’s and the daemon’s key. Both must exist already: without the flag it would generate the missing one.
Any other sync option given before a command is an error, for example
-a is a sync option and cannot be used with 'gc'. That holds for sync
and list too: write irsync sync -av …, not irsync -av sync ….
irsync daemon
irsync daemon [--config PATH] [--passphrase-file PATH]
[--listen ADDR]... [-v] [-q]
[--run-as-root-i-know-what-i-am-doing]
Serves the exports in the config file to the peers they are granted to, until
it is interrupted. At start it prints endpoint id: <EndpointId> and one
listening on: <socket> line per bound socket on stdout. Logs go to stderr at
warning level, counted like the sync’s -v: -vv gives info, -vvv debug,
-vvvv trace, -vvvvv trace plus every protocol message, -q errors only,
and RUST_LOG overrides all of them. When stdout is a terminal, the daemon
first prints a banner with its version, relay and discovery settings.
| Flag | Meaning |
|---|---|
--config PATH | The config file. |
--passphrase-file PATH | Read the passphrase of an encrypted daemon key from the first line of this file. |
--listen ADDR | Bind this socket (ip:port, [ipv6]:port or host:port; port 0 lets the system pick) instead of the config’s listen list. Repeatable, at most one IPv4 and one IPv6. |
--run-as-root-i-know-what-i-am-doing | Start even as root. Without it, or allow_root = true under [daemon], the daemon refuses to run as root: it has not had a security audit, and as root any client with write access can create setuid files and device nodes. |
-v, --verbose | Nothing extra; -vv and up log more. See Flags every command takes. |
-q, --quiet | Log errors only. |
irsync index
irsync index [-n] [-v] [-q] [--config PATH]
[--export NAME]... [ROOT]...
| Flag | Meaning |
|---|---|
-n, --dry-run | Walk and count what would be hashed; read nothing. |
-v, --verbose | Nothing extra; -vv and up log more. |
-q, --quiet | Log errors only and print no summary. |
--config PATH | The config file, for state_dir and the exports. |
--export NAME | Hash the files of the daemon’s export NAME too; all for every export. Repeatable. Run it as the daemon’s account, with its --config, so the rows land where the daemon reads them. |
Give at least one ROOT or --export.
irsync gc
irsync gc [-n] [-v] [-q] [--config PATH]
| Flag | Meaning |
|---|---|
-n, --dry-run | List what would be removed without removing anything. |
-v, --verbose | Nothing extra; -vv and up log more. |
-q, --quiet | Log errors only and print no summary. |
--config PATH | The config file, for state_dir. |
Environment
| Variable | Effect |
|---|---|
IRSYNC_PASSPHRASE | The passphrase of an encrypted key, when no --passphrase-file is given. |
IRSYNC_RSH | The remote shell for irsync pair, when no --rsh is given. |
RUST_LOG | The log filter, in place of the one -v and -q choose. |
OTEL_EXPORTER_OTLP_ENDPOINT | Export traces and metrics over OpenTelemetry to this endpoint. Overrides [telemetry] in the config file. |
TERM | dumb turns the live progress block off. |
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | Nothing got through: a configuration, identity or connection error, or every source failed. |
| 2 | The command line is wrong: an unknown flag, a bad value, a missing operand, or operands irsync rejects (both sides local, both remote, several sources on a pull, an empty host). |
| 23 | Partial transfer: some files could not be transferred, or some sources of a push failed while others synced. |
| 24 | Some source files vanished. Only --paranoid, in its final re-check, gives this. |
| 25 | Deletions stopped at --max-delete. |
Of these, 23, 24 and 25 have rsync’s meaning; 1 and 2 do not (rsync uses 1 for a syntax or usage error and 2 for a protocol incompatibility).
When several apply, 1 wins over 25, 25 over 23, and 23 over 24. A file listing, irsync HOST:PATH, is a dry-run pull and
uses the same codes; the export listing, irsync HOST:, exits 0 or 1.
The other commands exit 0 on success and 1 on an error, with these
additions: irsync index exits 23 when a file could
not be read or a directory could not be listed, irsync gc exits 23 when
something could not be read or removed (it goes on with the rest), and irsync config get exits
1 for a key that is not set and has no default.
Management commands
These commands read and edit the config file, ~/.config/irsync/irsync.toml
(see Configuration). There are four nouns, server,
client, export and grant, each with add, remove and list (server,
client and export also rename, client and export also set); id for the identities; config for any key by its dotted
path; and show for an overview.
A noun on its own runs its list: irsync server, irsync client, irsync export,
irsync grant, irsync id and irsync config print what is there and
leave the config file alone (irsync id creates the client’s key when
there is none). Arguments of list, such as a grant target, need list
typed out.
Every command here accepts -v and -q, before or after it; see the
command-line reference.
Every management command takes --config PATH to use another file. For a
noun the flag may stand before the noun, or before or after the verb:
irsync --config C export add ..., irsync export --config C add ... and
irsync export add ... --config C are the same.
Editing rules
- The commands keep the file’s comments and the order of its servers, clients and
exports. They write the tables in a fixed order and each value in one
spelling: a duration
"90"becomes"90s". Blank lines and inline tables are not kept. URLs and paths stay as you wrote them. The first edit of a file rewrites it this way. A missing file is the same as an empty one; the first edit creates it. - A file that does not load must be fixed by hand. The error names the line.
- While a command edits the file,
irsync.toml.locksits beside it, and a second editing command is refused. Delete the lock only if noirsyncis running. - The edited file is checked before it is written. An edit that would leave a
file
irsynccannot load is refused, and the file stays as it was. - An export name may not be empty, contain
/, or be one of the reserved words. A server or client name may not be empty, contain:or/, beallor*, or be anEndpointId.
Remote use
Most of these commands also work on a server from afar, with
irsync remote SERVER in front: irsync remote myserver export list. See
irsync remote and
the how-to “Manage a server from your client”. It needs
admin on the server.
| Remote | Not remote |
|---|---|
export list, add, remove | export set, export rename |
grant list, add, remove | config set, config unset |
client list, add, remove, rename, set | id |
show, config get, config list | server |
A remote export add takes an absolute path or one that starts with ~,
quoted so that your shell leaves it alone. It has no --fsync. A client cannot remove or lower its
own admin right this way.
A running daemon picks up client, export and grant changes on its next
connection; nothing needs a restart.
server
| Command | Effect |
|---|---|
irsync server add NAME ID [--relay default|disabled|URL] [--address ADDR]... [--parallel N] [--reconnect DUR] [--dial-retries N] [--dht yes|no] [--dns yes|no] [--mdns yes|no] [--pq-key-exchange prefer|require] | Add a server: a name for the EndpointId of a daemon you connect to. For an existing name, change the id and the keys given. Keys not given stay as they are. Prints NAME: ID, or NAME: OLD -> NEW when the id changed. |
irsync server remove NAME | Remove a server. Grants never name servers, so none can stop it. |
irsync server rename OLD NEW | Rename a server. It keeps its place, keys and comments. Refused, with nothing changed, when OLD is no server, NEW is not a valid name or NEW is a server already. Only the config file changes: scripts and commands that use OLD keep using it. |
irsync server list | One NAME: ID line per server, then one indented key = value line per other key. |
The flags of server add set the keys of the server’s table; see
Configuration for what each does. --address
replaces the stored list and may be repeated. --dht, --dns and --mdns take
yes or no (also true or false): they store the setting, where a sync’s
--no-dht, --no-dns and --no-mdns turn a lookup off for one run. --pq-key-exchange require refuses this
server when it does not offer post-quantum key exchange.
client
| Command | Effect |
|---|---|
irsync client add NAME ID | Add a client: a name for the EndpointId a machine has as a client (what irsync id show prints on that machine). For an existing name, change the id; grants that name it then apply to the new id, and a note on stderr says so. Prints NAME: ID, or NAME: OLD -> NEW when the id changed. |
irsync client remove NAME [-f] | Remove a client. Refused while a grant names it, and the error lists where: without the client those grants would match nobody. A grant written as the EndpointId counts as naming the client, unless another client has the same id. -f/--force removes those grants, then the client. |
irsync client rename OLD NEW | Rename a client, and every grant that names it: in every export. Its all_exports, all_paths and admin stay with it. A grant written as the EndpointId counts as naming the client. The client keeps its place and comments. Refused, with nothing changed, when OLD is no client, NEW is not a valid name or NEW is a client already. Only the config file changes. |
irsync client set NAME KEY=VALUE... | Set the server-wide rights of a client. KEY is all_exports, all_paths or admin, and VALUE is rw, ro or none (none removes the right). Give several pairs to change them together: if one is wrong, nothing changes. irsync client set myclient all_paths=rw lets myclient reach any path this account can. Prints the client’s rights afterwards. See Rights on a client. |
irsync client list | One NAME: ID line per client, followed by all_exports=VALUE all_paths=VALUE and admin=VALUE for each right it has. |
A server and a client may have the same name; the two commands do not touch each other’s entries.
export
| Command | Effect |
|---|---|
irsync export add NAME:PATH [--read-only] [--index-at-start] [--fsync] | Export a directory under NAME. For an existing name, change its path and turn the flags given on; its other settings and its grants stay. Prints the daemon’s EndpointId on stdout, generating the daemon’s key if it does not exist yet. |
irsync export add PATH [--read-only] [--index-at-start] [--fsync] | The same, named after the directory’s last component. |
irsync export set NAME KEY=VALUE... | Set an export’s settings. KEY is read_only, index_at_start or fsync, and VALUE is true or false. Give several pairs to change them together: if one is wrong, nothing changes. Prints the export’s settings afterwards. |
irsync export rename OLD NEW | Rename an export. Its path, settings and grants stay, and so does its place in the file. Refused, with nothing changed, when OLD is no export, NEW is not a valid export name or NEW is an export already. Clients then name it NEW in HOST:PATH. |
irsync export remove NAME | Stop exporting a directory. Its grants go with it. |
irsync export list | One block per export: NAME: PATH, then read_only, index_at_start and fsync when set, then its grant lines. |
export add joins a relative PATH onto the working directory, expands a
leading ~ (irsync export add home:~ exports the home directory), and
requires an existing directory. The text before the first : is a name only
when it has no /. --read-only sets read_only, which refuses pushes from
everyone; --index-at-start sets index_at_start, which hashes the export’s
files into its index whenever the daemon starts; --fsync sets fsync, which
flushes every file pushed into the export to disk. A flag left out leaves the
setting alone; to turn one off, use irsync export set NAME KEY=false. To
hash the files once, now, run irsync index --export NAME. See
Seed the index.
grant
| Command | Effect |
|---|---|
irsync grant add EXPORT WHO [--ro] | Grant WHO read-write access to EXPORT, or read-only access with --ro. An earlier grant of the same peer there is replaced. For every export or any path, use irsync client set; grant add all is refused, with a hint. |
irsync grant remove EXPORT WHO | Remove WHO’s grant on EXPORT. irsync grant remove all WHO removes WHO from every export’s own list. It leaves their all_exports, all_paths and admin alone, and says so when WHO still has one; those go with irsync client set. irsync grant remove EXPORT all empties an export’s grants. |
irsync grant list | Every grant: an all_exports: block, an all_paths: block, an admin: block (the clients that hold each right), then one block per export. |
irsync grant list EXPORT | One export’s grants. all_exports, all_paths and admin list the clients that hold that right. |
irsync grant list WHO | What one peer may reach: all_paths: rw or all_paths: ro and admin: rw or admin: ro first when it has those rights, then one NAME: rw or NAME: ro line per export, marked (all_exports) when the access comes from all_exports and (read_only export) when a read-write grant is capped by read_only. |
A client paired over ssh is listed by its host name, which irsync pair saved
in [clients].
WHO is a client name, an EndpointId, a pasted ssh-ed25519 AAAA... public key
line, or the path of a .pub file holding one. A key’s comment is kept as a
TOML comment at the end of the entry’s line. Removing the grant removes that
comment; comment lines above it stay. A peer that [clients] has a name for is stored
by that name, however it was named. A server name is not a WHO. There is no open access: all and * are
refused as WHO in grant add.
Reserved words
The words all, all_exports, all_paths and admin are reserved: no
export has one of them as its name.
id
| Command | Effect |
|---|---|
irsync id list [--identity FILE] [--passphrase-file PATH] | Print every identity this machine has: client: with the client’s public key line and EndpointId, then daemon: with the daemon’s when a daemon key exists. Generates the client’s key if no key serves; never the daemon’s. |
irsync id show [--identity FILE] [--passphrase-file PATH] | Print client:, then the client’s public key line and EndpointId, generating the key if no key serves. On a machine that also has a daemon key, a note on stderr says that clients connect to the daemon’s EndpointId and that irsync id show --daemon prints it. |
irsync id show --daemon | The same for the daemon, under daemon:. Never generates the daemon’s key: without one it fails and says how to make one. |
irsync id show -a | Both, each under its label. |
irsync id generate [--daemon] [--out PATH] [-f] [--passphrase-file PATH] | Write a new Ed25519 key pair, with the public key beside it as .pub: the client’s (default) or with --daemon the daemon’s, at its configured path (for the client’s, --identity FILE when given) or at --out PATH, and print the public key line and EndpointId. Refuses to overwrite an existing key or .pub file unless given -f/--force. With --passphrase-file, the private key is written encrypted with the passphrase on the first line of that file (its line ending, LF or CR+LF, is not part of it). A file that is missing or empty is an error and nothing is written. IRSYNC_PASSPHRASE does not encrypt a new key. |
Some commands generate a missing key automatically: a sync, a listing,
id show, id list, show, export add and the daemon. A key generated
automatically is never encrypted. So with --passphrase-file, these commands
do not generate a missing key. They fail, write nothing, and tell you to run
irsync id generate --passphrase-file PATH first. Add --daemon for the
daemon’s key.
The client’s key is found the way ssh picks one; see
Configuration. --identity FILE
names it for one command. After irsync id generate has written ~/.config/irsync/id_ed25519, ~/.ssh/id_ed25519 is no
longer consulted. Replacing a key with --force is permanent: every grant made
for the old key stops working.
config
| Command | Effect |
|---|---|
irsync config get KEY | Print a key: a bare scalar, one array element per line, or a table’s keys as key = value lines, all as the file holds them (a path’s ~ is not expanded). An unset key prints its default; a key with no value and no default prints nothing and exits 1. |
irsync config set KEY VALUE... | Set a key in its type: true or false, an integer, a duration such as 30m, a path, a URL, an EndpointId. An array key takes one VALUE per element, and none for an empty array. Tables are created as needed. |
irsync config unset KEY | Remove a key, or a whole table (irsync config unset servers.myserver). A table left empty goes with it. Removing a client this way is refused while a grant names it, as with client remove. |
irsync config list | Every key the file sets, as dotted.key = value, in the order the file is written in: the tables in a fixed order, and each table’s keys in a fixed order. |
These keys have no default: the tables themselves, defaults.relay and
daemon.relay (n0’s relays are used), daemon.debug_addr (off),
telemetry.otlp_endpoint, every key of a server (each falls back to
[defaults]’s), every key of a client, and an export’s path, rw and
ro. An export’s flags, such as read_only, default to false for an
export that exists.
KEY is a dotted path such as daemon.listen or servers.myserver.relay. A client has the keys clients.NAME.client_id, all_exports, all_paths and admin. config_version can be read but not set.
Quote a segment that holds a dot: exports."www.example.com".path. An unknown
key is an error.
config writes what you say; the nouns know what you mean. export add joins
a relative path onto the working directory and checks that the directory
exists, and grant add reads a pasted key line or a .pub file. In contrast,
irsync config set exports.photos.path ./x is refused, because the file wants
an absolute path, and irsync config set exports.photos.rw ~/myclient.pub
writes that string as a grant entry that matches nobody.
show
irsync show [--identity FILE] [--passphrase-file PATH]
Prints the config file’s path, the client’s EndpointId and public key line,
the servers as server list prints them under servers:, the clients (with their rights) as client list prints them under clients:, and under exports: the
daemon’s EndpointId and the exports as export list prints them. show generates
the client’s key if it does not exist yet, but never the daemon’s: without
one it prints daemon identity: none.
Remote addresses
A remote operand is HOST:PATH.
HOSTis a name from a[servers.NAME]table (see Configuration) or anEndpointId, in hex or z-base-32 as iroh prints it. Names match exactly; there are no patterns. Only servers count here: a client’s name is not looked up. The client pins theEndpointIdit dials: a daemon with another key fails the connection.- A
HOSTthat is neither is looked up among the saved servers by theirsshvalue: the address a server was first set up by finds that server again. When servers with differentEndpointIds share thatsshvalue, irsync stops and names them. AHOSTthat matches nothing is an error: it namesirsync pair HOST, which sets the server up over ssh, andirsync server add, which adds it by hand. A sync never uses ssh. - An IPv6 address goes in brackets:
[fe80::1]:PATH, ormike@[fe80::1]:PATH. PATHis sent to the daemon as typed and resolved on the daemon’s machine. The client does not interpret it, apart from the trailing slash.
An operand is remote when it has a : before its first /, as in rsync.
HOST may not be empty.
An operand that starts with [, or with USER@[, is read by its brackets
first:
| Operand | Read as |
|---|---|
[fe80::1]:PATH | remote: the IPv6 address is the host |
[myserver]:PATH | an error: only an IPv6 address goes in brackets |
[fe80::1:PATH | an error: a : and no closing ] |
[a:b]/c, [a:b], [notes]/a | a local path, whatever is in the brackets |
Write ./ before a local name that would otherwise be read as remote or
as an error: ./[myserver]:x.
Resolution order
The daemon reads PATH in this order:
- An export name, then a path inside it. When the first component of a
relative
PATHnames an export, the rest is resolved under that export’s directory:myserver:photos/2024is2024inside thephotosexport. A name counts only if the client may use that export: a grant on it, orall_exports(see Rights on a client). Any other export’s name is read as in step 2, as if the export were not there, also when the client may use that export’s directory through another export. - A path relative to the home directory of the account the daemon runs
as.
myserver:Picturesis~/Pictureson the daemon’s machine;myserver:andmyserver:~are the home directory itself, andmyserver:~/Picturesis the same asmyserver:Pictures. - An absolute path, as is:
myserver:/backup/myclient.
. and empty components are dropped. A .. component or a NUL byte is
refused.
Exports decide access
Whatever the spelling, the resolved path must lie inside an exported directory
that the client may use, and that export’s grants apply. A client may use an
export it has a grant on, and with all_exports every export made by hand.
A path outside every export the client may use is refused as “no access”,
whether or not it exists, so the answer reveals nothing about the daemon’s
file system.
A client with all_paths is the exception: it may reach any path the
daemon’s account can. When it uses a path that no export covers, the daemon
adds an automatic export for that path, for that client only, and the rules
below then apply to it. See Rights on a client.
Exports may be nested. A grant reaches everything below its export’s directory, exports nested inside it included. When the path lies inside several exports the client may use:
- the export with the longest path decides the session’s root and access;
- between exports with the same path, the one the operand named wins, then the
one with the better access (read-write over read-only,
read_onlyapplied).
Exports the client may not use take no part. A grant on an outer export
is therefore not stopped by an inner export, not even by a read_only inner
one, and the answer for a path never depends on where ungranted exports sit.
To let a client reach everything the daemon’s account can, give it
all_paths on the server:
irsync client set myclient all_paths=rw
irsync pair does this for the client it pairs. / itself is never
exported automatically. To sync the whole root as one tree, export it by hand
and grant it:
irsync export add root:/
irsync grant add root myclient
irsync export add home:~ exports the home directory.
Trailing slashes
rsync’s trailing-slash rule holds on both sides. A source that ends in /
copies the directory’s contents; one without copies the directory itself.
| Command | Result on the daemon |
|---|---|
irsync -a ~/Photos/ myserver:photos/ | The contents of ~/Photos in the photos export. |
irsync -a ~/Photos myserver:photos/ | ~/Photos as Photos inside the photos export. |
irsync -a myserver:photos/ ~/copy/ | The contents of the export in ~/copy. |
irsync -a myserver:photos ~/copy/ | The export as ~/copy/photos. |
Copying one file
A source may be a single file, in either direction. It lands where rsync
would put it, which depends on what the destination is before the copy. T
is the destination as typed on a push, and L the local destination on a
pull:
| Command | If a directory | If missing | If a file |
|---|---|---|---|
irsync f.iso myserver:T | T/f.iso | a file named T | T is updated |
irsync f.iso myserver:T/ | T/f.iso | directory T is created, then T/f.iso | error |
irsync myserver:dir/f.iso L | L/f.iso | a file named L | L is updated |
irsync myserver:dir/f.iso L/ | L/f.iso | directory L is created, then L/f.iso | error |
- A trailing slash on the file source (
f.iso/) is an error. A lone source that fails this way exits 1; with other sources, the run exits 23. - If
T/f.isoalready exists and is a directory, the copy fails and nothing is replaced. rsync would replace an empty directory;irsyncnever replaces a directory with a file. - An existing file is updated as it is inside a directory copy: delta
transfer,
.partfiles,--inplace,--append,-c,-u,-n,-iand the metadata flags all apply, and a dropped connection resumes. - Nothing else in the destination directory is touched.
--delete,--delete-excludedand--max-deleteare accepted and do nothing. --includeand--excludeare matched against the file’s name. An excluded file is not copied, and the run exits 0.- A symlink or special file as the source is treated as it would be inside a
directory copy: a symlink is copied as a link with
-lor-aand skipped otherwise; a device or special file needs-Dor-a. A source symlink is not followed. - Several sources may be files and directories mixed (push only). The destination is then always a directory, and each file lands under its own name.
irsync myserver:dir/f.isowith no destination lists that one file.- The missing parent directories of
Tare handled as for a directory destination. - On a push the daemon does not follow a symlink at
T. It works out where the link leads only inside the export. A symlink to a file there, or to a name that is not there, is replaced by the file. A symlink to a directory there is an error (“is a symlink to a directory”); name the real directory instead. A symlink with an absolute target, one that leads out of the export, or one that leads through another symlink is an error too (“is a symlink the daemon does not follow”), whatever it leads to.
A pull without a trailing slash first asks the daemon whether the path is a file, a directory or missing. That costs one extra short connection. A remote symlink as the last component counts as a file and is pulled as a link, even if it points to a directory. A remote file that does not exist is an error.
With all_paths, a push of a file to a missing T
exports T’s parent directory, which must already exist, and creates
nothing. The client then has lasting read-write access to that whole
directory. When T is a directory, or the destination ends in /, the
grant is as for a directory push.
Listing
A single remote operand lists instead of copying. irsync list does the
same, and takes myserver for myserver::
irsync myserver:prints the exports this client may reach, oneNAME PATH ACCESSline each,ACCESSbeingrworrowithread_onlyapplied.irsync myserver:photos/prints the files a pull would fetch, and writes nothing. It recurses unless--no-recursiveis given.
Configuration
One file holds everything: ~/.config/irsync/irsync.toml, or
$XDG_CONFIG_HOME/irsync/irsync.toml when that is set. It is optional; a
missing file is the same as an empty one, and every key has a default except
where noted. The management commands edit it for you and keep
its comments and the order of its servers, clients and exports (they rewrite the rest in
one standard form); irsync config reads and writes any key; you can also edit it by
hand.
Every command takes --config PATH to use another file. Unknown keys and
tables are errors that name the file, the line and the key.
Values
- A duration is
N[s|m|h|d], such as90s,30m,1hor7d; a number without a unit, as a string or as a TOML integer, is seconds. - A path may start with
~, which stands for the home directory. - An
EndpointIdis hex or z-base-32, as iroh prints it. - An address is
ip:port,[ipv6]:portorhost:port.
The whole file
Every table, with the defaults except where marked:
config_version = 2 # written by irsync; always first
unsafe_config_allowed = false # true: skip the permission checks
state_dir = "~/.local/state/irsync"
[defaults] # this machine as a client
identity = "~/.config/irsync/id_ed25519"
parallel = 128
reconnect = "1d"
dial_retries = 4
ssh_install = true # false: copy nothing to the server
relay = "default" # n0's relays; "disabled" or a URL
dht = true # the lookups
dns = true
mdns = true
congestion = "bbr" # or "cubic", for pushes
pq_key_exchange = "prefer" # or "require"
idle_timeout = "0" # "0": never
[daemon]
identity = "~/.config/irsync/daemon_ed25519"
idle_timeout = "30m" # "0" disables
dormant_session_timeout = "7d"
max_dormant_sessions_per_key = 25 # 0: no limit
# No default: any address, on a port picked at start.
listen = ["0.0.0.0:4000", "[::]:4000"]
portmap = true # UPnP, PCP and NAT-PMP
relay = "default" # n0's relays; "disabled" or a URL
dht = true # where clients may find the daemon
dns = true
mdns = true
congestion = "bbr" # or "cubic", for pulls
pq_key_exchange = "prefer" # or "require"
debug_addr = "127.0.0.1:9464" # no default: off
allow_all_paths = true # false: ignore all_paths
allow_root = false # true: let the daemon run as root
[telemetry]
otlp_endpoint = "http://localhost:4318" # no default: off
otlp_protocol = "http" # or "grpc"
# One [servers.NAME] table per machine this one connects to.
[servers.myserver]
endpoint_id = "4a29f16a4f80a3fd171ef5573c106dbda470ec24f5a97933752746b567ab9aff"
relay = "https://relay.example.net" # the rest is optional
dht = false
dns = false
mdns = false
congestion = "cubic"
pq_key_exchange = "require"
parallel = 64
reconnect = "1h"
dial_retries = 2
ssh = "myserver" # set by irsync pair
# A server dialled at its address: no relay, no lookups.
[servers.mynas]
endpoint_id = "069ffbb125300737c2767fed918cd5f4bc12b3102fdd9009a2a1320e2ebd3191"
address = ["192.168.1.10:4000"]
# One [clients.NAME] table per machine this one's daemon lets in.
[clients.myclient]
client_id = "a3e4753e5ea74e64e745e9c4d10b0fd751dbe03049d742eb0ea545c89703dfba"
all_exports = "ro" # every hand-made export
all_paths = "rw" # any path this account can
admin = "rw" # manage this server remotely
# What the daemon shares and with whom. Entries in rw and ro are
# names from [clients.*] or EndpointIds.
[exports.photos]
path = "/srv/photos"
rw = ["myclient"]
index_at_start = false
fsync = false
[exports.docs]
path = "/srv/docs"
read_only = true
ro = ["myclient"]
# Made by the daemon when a client with all_paths first used it.
[exports.auto-srv-music]
path = "/srv/music"
auto = true
rw = ["myclient"]
File permissions
The config file, a private key and a passphrase file are for their owner only, as sshd asks of a key. irsync stops when one of them:
- can be read, written or run by its group or by other users (any mode bit
beyond
0700), or - belongs to another user who is not root. Root itself may use a file of any owner.
The config file is checked first, before anything else in it counts and before irsync does anything else. The error names the file, its mode and the fix.
The management commands refuse such a file too, so fix it with chmod 600.
A key or a passphrase file is checked when a command loads it. A key is
checked whether it is encrypted or not.
| Key | Default | Meaning |
|---|---|---|
unsafe_config_allowed | false | true turns these checks off for the config file itself, the keys and the passphrase file. It goes at the top of the file, outside every table. |
Leave it off unless you have to share a file. Whoever can write the config file can grant themselves access, and whoever can read a key or its passphrase can act as that identity. A running daemon reads the config file for every connection: if the file is opened up while the daemon runs, the daemon refuses connections until it is closed again.
Only regular files are checked. A passphrase read from a pipe, such as
--passphrase-file <(pass show irsync), is used as it is.
Identity and state
| Key | Default | Meaning |
|---|---|---|
state_dir | ~/.local/state/irsync; $XDG_STATE_HOME/irsync when that is set | Where the client and the daemon keep their indexes, sessions and partial-file records. |
The client’s key is identity in [defaults]. It is looked
up the way ssh picks one: --identity; else identity when the file sets
it; else ~/.config/irsync/id_ed25519 when it exists; else ~/.ssh/id_ed25519 when it exists, read as it is and never
written; else a key generated at ~/.config/irsync/id_ed25519. A key named by
--identity or identity is the whole answer: when it is missing, a key is
generated there. An encrypted key needs a passphrase, from
--passphrase-file, IRSYNC_PASSPHRASE or a prompt on a terminal. To make
an encrypted key, run irsync id generate --passphrase-file PATH. Only
file-based Ed25519 keys work.
The client and the daemon use different keys, so both can run in one account on one machine and reach each other.
Defaults
[defaults] holds this machine’s settings for when it connects to a server:
its key, and the defaults for every sync. Do not mix it up with
[clients.NAME], the machines this machine’s daemon lets in. A server’s table
overrides these defaults for that server, and a command-line flag overrides both: a sync resolves each
setting from the flag, then the server’s table, then [defaults], then the
built-in default.
| Key | Default | Meaning |
|---|---|---|
identity | ~/.config/irsync/id_ed25519 | The client’s private key, an OpenSSH Ed25519 key file. See Identity and state. Flag: --identity. |
parallel | 128 | Data streams a push keeps open at once; at least 1. Flag: --parallel. |
reconnect | 1d | How long a sync keeps redialling after a dropped connection; 0 gives up at once. Flag: --reconnect. |
dial_retries | 4 | How often a sync retries a server that has not answered yet, waiting about 1, 2, 4, 8 seconds and so on between tries, before it gives up; 0 gives up on the first failure. reconnect applies only once the server has answered. A server irsync pair saved is dialled once when no dial_retries is set: not here, not in its table and not by the flag. Flag: --dial-retries. |
ssh_install | true | Copy irsync to the server when irsync pair sets it up. false copies nothing: pair uses the irsync already at ~/.local/bin/irsync there, and stops if it is missing or another version. Flag: --no-ssh-install. |
relay | default | Which relay to use when no direct path works: default for n0’s public relays, disabled for direct connections only (the lookups stay on), or the URL of a relay of your own. Flag: --relay. |
dht | true | Look daemons up in the mainline DHT. Flag: --no-dht. |
dns | true | Look daemons up through n0’s DNS service. Flag: --no-dns. |
mdns | true | Look daemons up with mDNS on the local network. Flag: --no-mdns. |
congestion | bbr | QUIC’s congestion controller when the client sends, that is for a push: bbr or cubic. |
pq_key_exchange | prefer | require: refuse a daemon that does not offer the post-quantum key exchange. See Post-quantum key exchange. Flag: --pq-key-exchange. |
idle_timeout | 0 | Drop a connection that moves no data and no control message for this long, and reconnect; 0 never does. The daemon’s own is [daemon] idle_timeout. Flag: --idle-timeout. |
congestion picks the congestion controller of the side that sends: the
client’s (the server’s, else [defaults]’s) for a push, the daemon’s for a pull.
When to choose cubic over bbr, with measurements, is in
Connections.
Post-quantum key exchange
irsync always offers a key exchange that also holds against a quantum
computer (X25519MLKEM768, see
Networking), and uses it
when the other side offers it too. pq_key_exchange says what happens when
the other side does not:
prefer, the default: the connection is made with the classical key exchange. Someone who records it could decrypt it once a large quantum computer exists.-vvshows which key exchange a connection got.require: the connection is refused, before any file name or data is sent. The side that refuses says why, and the other side prints it.
Each side decides for itself. On the client it is the flag, else the server’s
table, else [defaults]. On the daemon it is pq_key_exchange in
[daemon], and it holds for every client: there is no setting
per export or per grant yet. A daemon tells only a client that has a grant;
a key without one is turned away as before.
Servers
[servers.NAME] names a machine this one connects to. The name is what you
type before the colon in NAME:PATH. The
irsync pair command writes the
entry for you. A name may not be empty, contain : or /, be all or *, or be
an EndpointId.
| Key | Default | Meaning |
|---|---|---|
endpoint_id | required | The EndpointId of the server’s daemon: the one dialled for NAME:PATH. The client pins it. |
address | none | Dial these addresses directly, with the relay, DNS, DHT, mDNS and the port mapper off. The client binds to the local address it reaches the first address of each IP version from, and offers the daemon no other. relay, dht, dns and mdns cannot be set beside it, and [defaults]’s do not apply to this server. Cannot be combined with --relay. |
relay | [defaults]’s | This server’s relay: default, disabled or a URL, as in [defaults]. It wins over [defaults]’s, whatever each says. |
dht | [defaults]’s | Look this server up in the mainline DHT. |
dns | [defaults]’s | Look this server up through n0’s DNS service. |
mdns | [defaults]’s | Look this server up with mDNS. |
congestion | [defaults]’s | The congestion controller for pushes to this server. |
pq_key_exchange | [defaults]’s | require: refuse this server when it does not offer the post-quantum key exchange. |
parallel | [defaults]’s | Data streams a push to this server keeps open at once; at least 1. |
reconnect | [defaults]’s | How long to keep redialling. |
dial_retries | [defaults]’s | How often to retry this server before it has answered. A server with ssh is dialled once when neither this nor [defaults] sets it. |
ssh | none | The ssh destination this server was set up through, such as myserver or me@myserver. irsync pair writes it. It is what irsync pair logs in to. A sync never uses it, except to find the server when you type that address. irsync pair for a saved server checks it again, and never adds back all_paths that was removed on the server. |
ssh_aliases | none | Other ssh destinations that were typed for this server, such as its address: ["192.168.1.5"]. Typing one of them finds this server, as typing its ssh value does. irsync pair adds to it; nothing is ever dialled through it. These are not server names: they do not work with irsync server. |
--address on the command line replaces the server’s address list.
Clients
[clients.NAME] names a machine that this machine’s daemon lets in. Grants
(rw and ro in an export) name clients, never servers. The name has the same rules as a server’s.
| Key | Default | Meaning |
|---|---|---|
client_id | required | The machine’s EndpointId as a client: the key it signs in with. A grant that names NAME is for this id. |
all_exports | none | "rw" or "ro": this client reaches every export you made by hand, read-write or read-only. See Rights on a client. |
all_paths | none | "rw" or "ro": this client reaches any path the daemon’s account can, with automatic exports. "ro" reads any path and writes none. |
admin | none | "rw" or "ro": this client may manage this server remotely. "rw" reads and changes exports, clients and grants; "ro" only reads. See Rights on a client. |
Only a named client holds all_exports, all_paths or admin. A key you did not
name as a client cannot have them. A value left out means no right.
irsync client set sets them; see Management commands.
A server and a client may have the same name. They are two entries, for the
two ids a machine has: its daemon’s, which you dial, and its own as a client,
which grants are for. irsync pair writes both sides: the server’s name on the
client, and the client’s host name on the server.
Config version
The file starts with config_version = 2. irsync writes it first, every time
it saves the file. You do not set it, and irsync config set refuses it. A
file without it is read as version 2. Any other version is an error.
Daemon
[daemon] configures irsync daemon. On SIGHUP the daemon re-reads this
table and rebinds. Changes to debug_addr, to [telemetry] and to the
top-level state_dir take effect at the next start; the reload logs each at
warn.
| Key | Default | Meaning |
|---|---|---|
identity | ~/.config/irsync/daemon_ed25519 | The daemon’s private key, generated when missing. |
idle_timeout | 30m | Drop an authenticated connection that has had no traffic and no local progress, such as hashing or writing, for this long. The client reconnects and resumes. 0 disables it. |
dormant_session_timeout | 7d | How long the daemon keeps an interrupted session, and its partial files, for a client to resume. |
max_dormant_sessions_per_key | 25 | How many interrupted sessions one client key may leave waiting in an export. When a key has more, the daemon drops the one that went longest without progress; the sync it belonged to plans afresh on its next run. A session that a connection is using does not count. 0 removes the limit. |
listen | none | The sockets to bind, at most one IPv4 and one IPv6; port 0 lets the system pick. Without it the daemon binds any address on a port picked at start. The daemon offers clients the addresses it binds for extra paths: a specific address offers only that one, any address offers every interface. Flag: --listen. |
portmap | true | Ask the router for a port mapping with UPnP, PCP or NAT-PMP. Set false in isolated setups. |
relay | default | default for n0’s public relays, disabled for no relay (direct connections only), or the URL of a relay of your own. |
dht | true | Publish the daemon’s addresses in the mainline DHT. With relays disabled the records carry no addresses, and the daemon warns. |
dns | true | Publish them through n0’s DNS service. |
mdns | true | Announce the daemon with mDNS on the local network. |
congestion | bbr | The congestion controller when the daemon sends, that is for a pull. |
pq_key_exchange | prefer | require: close the connection of a client that does not offer the post-quantum key exchange, for every export. The client is told to upgrade. See Post-quantum key exchange. |
debug_addr | off | Serve metrics and span timings over HTTP at IP:PORT; a bare port means 127.0.0.1. |
allow_all_paths | true | Honour every client’s all_paths. false: the daemon ignores all_paths and makes no automatic exports, so clients reach only the exports granted to them. |
allow_root | false | Let the daemon run as root. Without it, or the flag --run-as-root-i-know-what-i-am-doing, a daemon started as root exits at once. See Do not run it as root. |
Telemetry
[telemetry] turns on OpenTelemetry export, for the client and the daemon.
The OTEL_EXPORTER_OTLP_* environment variables take precedence.
| Key | Default | Meaning |
|---|---|---|
otlp_endpoint | off | The collector’s base URL. |
otlp_protocol | http | http (HTTP with protobuf) or grpc. |
Exports
[exports.NAME] shares a directory under NAME. The name is the first
segment of a HOST:PATH, so it may not be empty or contain /, and it may not
be all, all_exports, all_paths or admin. Those words are reserved.
| Key | Default | Meaning |
|---|---|---|
path | required | The directory, an absolute path; ~ is expanded. |
read_only | false | Refuse pushes from everyone, even from clients under rw. Flag: irsync export add --read-only. |
index_at_start | false | Hash the files already in the export into its index whenever the daemon starts, so files irsync did not place are reused. irsync index --export NAME does the same once. Flag: irsync export add --index-at-start. |
fsync | false | Flush every file a push writes to disk before it is renamed into place, as if the client had passed --fsync. Read on every connection. Flag: irsync export add --fsync. |
rw | [] | Clients with read-write access: client names or EndpointIds. |
ro | [] | Clients with read-only access. |
auto | false | Marks an automatic export, one the daemon made for a client with all_paths; see Rights on a client. |
Rights on a client
Three keys of [clients.NAME] are rights over the whole server. Each is
"rw" or "ro". Left out, the client has no such right.
all_exportsreaches every export you made by hand, now and later. An export’s ownrworroentry for the client wins over it. It never reaches an automatic export (auto = true).all_pathsreaches any path the daemon’s account can."rw"reads and writes;"ro"reads any path and writes none.irsync client set NAME all_paths=rwsets it, andirsync pairsetsall_paths = "rw"on its client.adminlets the client manage this server from afar."rw"reads the exports, clients and grants and changes them;"ro"only reads. It gives no access to any file.irsync client set NAME admin=rwsets it, andirsync pairsetsadmin = "rw"together withall_paths = "rw".
When a client with all_paths uses a path that no export covers, the daemon
adds an automatic export for it, auto = true, named auto- and the path
with - between its parts (/srv/music becomes auto-srv-music), listing
that client only. The export is the directory itself, or the directory that
holds a file. A push to a directory that does not exist yet creates it, when
its parent exists; a client with all_paths = "ro" cannot push, so it
creates no directory. A push to the home itself (myserver:) exports the whole
home. / is never exported automatically; add that by hand. Remove an
automatic export with irsync export remove.
Access through an automatic export is always the client’s current
all_paths level, whatever the export file says. Lowering all_paths, or
removing it, or setting daemon.allow_all_paths = false, applies at once,
also to the automatic exports already made. The exports themselves stay in
the file. To share such a directory with other clients, delete its auto = true
line: it is then an ordinary export.
How grants combine:
- A key that no entry names is rejected before any protocol message is read. There is no open access.
- A client’s entry in an export’s own table decides its access to that export;
without one, its
all_exportsdoes. An export’sroentry therefore limits a client whoseall_exportsis"rw". - Within one table,
rwwins overro. A client written under two names with one id gets the higher level of each right. read_onlycaps everyone at read-only.- An entry that names no client and is no
EndpointIdmatches nobody; the daemon logs a warning for it. A server’s name is no client name. - Whenever
irsyncsaves the file, it writes a client by its[clients]name: anEndpointIdin a grant list that has a client becomes that name, also one that was already in the file. With two clients for oneEndpointIdit writes the first in alphabetical order. An entry named twice is kept once. - A grant by name follows the client. If the client entry later gets another
client_id, the grant is for that one.
How a remote path finds its export, nested exports included, is described in Remote addresses.
Files and state
What irsync reads and writes outside the trees it syncs, and what it leaves
inside them.
Config directory
All under ~/.config/irsync/, or $XDG_CONFIG_HOME/irsync/ when that is
set, all optional. There is no lookup under /etc; a daemon run system-wide
is given --config (see
Run the daemon).
| File | Holds |
|---|---|
irsync.toml | The whole configuration: state_dir, [defaults], [daemon], [telemetry], the [servers.*] and [clients.*] tables, and the [exports.*] tables. --config PATH names another file, and its lock sits beside it. The keys below stay in the config directory all the same, unless [defaults] identity and [daemon] identity in that file name other paths. See Configuration. |
irsync.toml.lock | Present only while a management command edits the file. See Management commands. |
id_ed25519, id_ed25519.pub | The client’s key, generated when no other key serves. See Configuration. |
daemon_ed25519, daemon_ed25519.pub | The daemon’s key, [daemon] identity, generated when missing by the daemon or irsync export add, or on demand by irsync id generate --daemon. |
Generated private keys are written with mode 0600, in OpenSSH format. irsync
refuses a key that other users can read or write; see
File permissions.
The .pub file beside each holds the public key line. irsync id show prints the
EndpointId of either key, under a client: or daemon: label; see
the id commands.
A new irsync.toml is written with mode 0600, since it names exports, peers
and grants. An existing one keeps the mode it has when a management command
saves it. irsync refuses a config file that other users can read or write,
unless the file sets unsafe_config_allowed = true.
State directory
state_dir defaults to ~/.local/state/irsync, or $XDG_STATE_HOME/irsync when
that is set.
irsync reads XDG_CONFIG_HOME and XDG_STATE_HOME only when they hold an
absolute path, as the XDG rules say, and only on Linux, macOS and the other
Unix systems. On Windows the config directory is %APPDATA%\irsync and the
state directory %LOCALAPPDATA%\irsync. The client and the daemon use the same layout.
| Path | Holds |
|---|---|
index/<hash>.sqlite | One SQLite database per root: a local directory the client synced or indexed, or an export. <hash> is 32 hex digits of the BLAKE3 hash of the root’s canonical path; the database records the path too. |
index/<hash>.sqlite-wal, -shm | SQLite’s write-ahead log and shared memory, beside each database. |
daemon.lock | Held by the running daemon, so a second daemon with the same state directory refuses to start. It holds the daemon’s pid, the path of its program (exe) and its version, one key=value line each. irsync pair reads it to tell whether a daemon runs and which build it is. |
daemon.addr | Where the running daemon can be reached right now: its pid, its home relay and each direct addr, one key=value line each, rewritten whenever they change. irsync pair passes them to the client, so the first sync to a daemon it just started does not wait for the daemon to appear in the DHT or DNS. |
daemon.log | The log of a daemon that irsync pair started in the background or made a launchd agent on macOS, at info level (-vv). A daemon that runs as a systemd service logs to the service manager (journalctl --user -u irsync). A daemon you start yourself logs to stderr instead. |
Each database holds:
- the file hashes of the root, which let a session skip unchanged files and reuse chunks of renamed and copied ones;
- the progress of partial files, so that an interrupted transfer resumes where it stopped;
- dormant sessions, so that the next run of the same sync resumes its plan;
- the time of the last garbage collection.
Exports with the same path share one database.
The databases hold the name and hashes of every file in the root. The index
directory is therefore kept at mode 0700, and irsync creates a missing state
directory with mode 0700 too. daemon.log is created with mode 0600.
The whole directory is safe to delete. The next sync rebuilds what it needs, at the cost of hashing files again and of losing the sessions that could have resumed. To remove only what nobody is coming back for, see Clean up state.
On a server paired over ssh
irsync pair (see Your first sync)
installs on the server the same files as install.sh: irsync and
fileset in ~/.local/bin, and irsync.1, fileset.1 and irsync.toml.5
under ~/.local/share/man. All five come along when pair sends release
files; when it sends the client’s own files, fileset and the manual pages
come only if they sit beside the client’s irsync. It replaces an irsync there when the client runs a
different build. It does not touch an irsync installed elsewhere.
Over ssh it then runs irsync ssh-setup, a hidden command that grants the client, makes the daemon’s key
when it is missing and starts the daemon, as a user service when it can: ~/.config/systemd/user/irsync.service on Linux or ~/Library/LaunchAgents/org.irsync.daemon.plist on macOS, each marked “Written by irsync pair”. The server’s config, keys and state
are the usual ones above; a daemon it starts in the background writes daemon.log in the
state directory.
In the synced trees
A receiver writes into temporary files beside their destinations and renames them into place:
| Name | What it is |
|---|---|
.irsync.<name>.part | A file being received. An interrupted transfer leaves it behind for the next run to resume. With --partial-dir DIR these files live under DIR instead. It has mode 0600 until it is placed, so other users cannot read a file while it arrives. |
.irsync.<name>.tmp | A symlink, hard link or special file being made, renamed into place at once. |
When the full name would exceed 255 bytes, <name> is cut and ~ plus 16
hex digits of a BLAKE3 hash of the whole name is put before the suffix, so two
long names with the same beginning still get different temporary files.
Names that start with .irsync. and end in .part or .tmp are never
listed, never accepted from a peer and never created as destinations.
With --paranoid, the sending side keeps reflink clones in a folder named
.irsync-clones-<uid> (the uid in decimal) in a writable directory on each
file’s filesystem. A directory named exactly .irsync-clones- followed by
digits is never listed and so never synced or deleted; a name such as
.irsync-clones-backup is an ordinary directory.
Garbage collection removes .part files and their progress records once
they have gone untouched for longer than dormant_session_timeout (7 days by
default; the client always uses 7 days), unless a stored session still lists
the file. It removes only regular files with that exact form of name, and
never follows a symlink. Progress records do not remember a --partial-dir:
a stale record whose .part file is not beside its destination is dropped,
and the file itself, if it exists, is collected on a later pass by its age.
When and how often collection runs is in
Clean up state.
Metrics
The metrics and spans that irsync emits, for the client and the daemon. How
to collect them is in Watch a transfer with telemetry.
Labels
Every irsync_* metric carries side (client or daemon) and role
(sender or receiver). The daemon’s per-session metrics also carry
export. There are no path or session-id labels, to keep the number of series
small; the session id is on the session span.
The busy-time and active-time counters, the irsync_bytes_* counters,
irsync_files_hashed_total and the disk counters are process-wide meters,
published once a second and at exit. They add up across the exports a daemon
serves and carry no export label.
The process_* metrics carry only side, and mode for CPU: they describe
the process, not a session.
The Prometheus names below are also the OTLP names. OTLP units follow the Unit column.
Counters
| Name | Unit | Extra labels | Meaning |
|---|---|---|---|
irsync_busy_microseconds_total | microseconds | activity | Time spent per activity, summed over tasks: walk, plan, hash, read, send, recv, write, place, delete, index_wait, and peer_wait. See Busy time and peer wait. |
irsync_active_microseconds_total | microseconds | activity | Wall time with at least one task doing each activity, without peer_wait, added when a session ends. |
irsync_sessions_total | count | outcome | Sessions ended: ok, partial, failed, max_delete. Counts connection attempts: a client session that reconnects counts failed and then ok. |
irsync_files_total | count | result | transferred, skipped, failed, created. failed counts the entries with at least one error, each once; errors about the session as a whole, such as an incomplete listing or a refused deletion pass, are not counted. |
irsync_entries_listed_total | count | kind | Source entries listed: regular, directory, symlink, special. |
irsync_bytes_literal_total | bytes | File data sent or received as literal chunk bytes. | |
irsync_bytes_matched_total | bytes | File data the receiver did not take from the sender (local copies, earlier progress, files already identical), counted when each file is placed; the sender counts what the receiver’s acknowledgement reports. | |
irsync_bytes_hashed_total | bytes | Bytes the hashers read. | |
irsync_files_hashed_total | count | Files the hashers read. | |
irsync_disk_read_bytes_total | bytes | File data irsync read from disk. | |
irsync_disk_write_bytes_total | bytes | File data irsync wrote to disk. | |
irsync_wire_bytes_total | bytes | dir | Bytes on the QUIC connection: tx or rx. |
irsync_deleted_total | count | Paths the receiver deleted. | |
irsync_reconnects_total | count | reason | Client reconnects: dial (no connection yet) or lost. |
irsync_quic_lost_packets_total | count | QUIC packets lost, sampled once a second. |
Histograms
| Name | Unit | Extra labels | Meaning |
|---|---|---|---|
irsync_phase_duration_seconds | seconds | phase | Wall time of each session phase: connect, handshake, list, plan, transfer, delete, reconnect. Phases overlap. |
irsync_file_transfer_seconds | seconds | From a file’s first request to its completion. | |
irsync_hash_wait_seconds | seconds | Time a role waited on a hash result. | |
irsync_fsync_seconds | seconds | Time to fsync a received file (only with --fsync, or a push into an export with fsync = true). | |
irsync_file_size_bytes | bytes | Size of each transferred file. | |
irsync_quic_rtt_seconds | seconds | QUIC path RTT, sampled once a second per connection. |
Gauges
| Name | Unit | Extra labels | Meaning |
|---|---|---|---|
irsync_sessions_active | count | Sessions the daemon is serving. | |
irsync_streams_open | count | Open data streams. | |
irsync_hash_queue_depth | count | Hash jobs waiting for a worker. | |
process_cpu_seconds_total | seconds | mode (user, sys) | CPU time of the process. |
process_max_resident_memory_bytes | bytes | Peak resident set size. | |
process_open_fds | count | Open file descriptors. |
Busy time and peer wait
irsync_busy_microseconds_total{activity} counts microseconds, not seconds,
because the metrics crate has only integer counters and seconds would lose
the fraction. Each activity counts the time tasks spent doing it, summed over
every task.
sendandrecvinclude network and flow-control waits on the data streams: a stream blocked on the peer’s window, or paused by--bwlimit, is still busy sending.peer_waitis wall time with no activity in progress at all: this side has no local work and waits for the peer.- An activity that runs on the other side shows up here as
peer_wait. For example, on a push the daemon plans, so the client’s planning time ispeer_wait, notplan. index_waitis time spent waiting on the index: for its lock while another task holds it, or for the entries this side queued to be written. The index is one SQLite database per root. Placed and hashed files, and entries of copy sources found gone, are queued for a writer thread that writes them in batches: whatever queues up within 10 ms of the first entry, since every commit empties the read connections’ page caches. Nobody waits for that, except once at the end of a session and before a lookup that needs freshly hashed files. The rarer writes, such as saving progress, take turns behind one lock, and lookups run on read connections of their own. The waiting task’s own activity,writeorplace, counts the same time too.hashon a receiver is the check of each arriving chunk against its hash, and the hashing of existing files. On a sender it includes encoding a chunk against the receiver’s bases, that is matching its blocks.placecovers every entry made or updated at the destination: placing received files, creating directories, symlinks and special files, and updating an entry’s metadata alone. Deciding what to do with an entry isplan.
Busy times can add up to more than the wall time: files are hashed, sent and
written in parallel, so ten workers busy for one second each count ten
seconds. They say where the work is, not how long the run took. peer_wait is
the only one that cannot overlap the others.
irsync_active_microseconds_total{activity} is the other half: the wall time
during which at least one task was doing the activity, so it never exceeds the
wall time. Busy divided by active is how many tasks did it at once, on
average. The -vv summary shows the active time, followed by ×N when that
average is 1.5 or more: place 18.2s ×14.8 is 18.2 s of the run during which
about fifteen files were being placed at a time. index_wait appears there as
index on the waiting line.
Transfer rates and goodput
Figures comparable to the progress block’s sent and synced rates and its
goodput can be drawn from the two byte counters. They are not identical: the
block counts matched data as soon as a file’s chunks are requested, while
irsync_bytes_matched_total counts it when the file is placed, and also
counts files found already identical. In PromQL, for the client:
# sent: bytes on the wire per second
sum(rate(irsync_bytes_literal_total{side="client"}[1m]))
# synced: bytes put in place per second, sent or matched
sum(rate(irsync_bytes_literal_total{side="client"}[1m]))
+ sum(rate(irsync_bytes_matched_total{side="client"}[1m]))
# goodput: synced bytes per byte on the wire (1 means nothing matched)
(sum(increase(irsync_bytes_literal_total{side="client"}[1h]))
+ sum(increase(irsync_bytes_matched_total{side="client"}[1h])))
/ sum(increase(irsync_bytes_literal_total{side="client"}[1h]))
Pick one side: the client and the daemon count the same bytes, so adding
both counts them twice. For a daemon, use side="daemon"; its counters add
up across all the sessions it serves. Matched bytes are counted when each file
is placed, so over a short range the synced rate jumps at the end of large
files; a range of a minute or more smooths that out.
Spans
Span names are stable. The per-file spans, file and its children, reach the
span sinks only with IRSYNC_TRACE_FILES=1.
session session_id, direction, side, role, endpoint_id, peer,
| resumed, source_index (client); at the end rtt_max_ms, cwnd,
| lost_packets, reconnects
+- connect attempt, path (client only, one per attempt)
+- handshake
+- list
+- plan
+- transfer
| +- file path, size, kind (new or delta) [IRSYNC_TRACE_FILES=1]
| +- hash (sender)
| +- send (sender)
| +- recv (receiver)
| +- place (receiver: rename, metadata, fsync with --fsync)
+- delete mode (each deletion pass)
+- reconnect attempt, reason (wait between attempts)
path on connect is direct or relay. session is a root span per
source. On the client it starts a new trace. On the daemon it is a child of
the client’s session span when the daemon exports over OTLP: the client’s
W3C trace context travels in its first message, so one sync is one trace
across both machines. The local EndpointId is the endpoint_id field on
session spans, not a resource attribute, and it is recorded only while spans
are exported over OTLP. Events logged inside a span pick up its context.
Log lines show that context too. The daemon’s lines, and the client’s under
-vv, start with the span stack and its fields, as in
session{session_id=… side="daemon" …}:transfer: ….
Overhead
The cost of the telemetry was measured as a push of a generated tree to a
local daemon on the same machine: irsync -a --no-resume, an empty
destination, a warm source index, release builds. The baseline is a build
without the telemetry code.
The tree is filegen run --seed 1 --steps 600000 --max-total-size 2G --max-file-size 192K: 22,000 files, 1.7 GiB, on tmpfs, so that disk speed
does not enter. The machine was shared and noisy, and single runs of the same
binary varied by up to 2x. The runs were therefore interleaved in random
order, and the table pools 23 runs per configuration over three batches. The
last two columns are from the last batch, 10 runs, as medians, and add the
client’s and the daemon’s CPU time, which is far steadier than wall time.
| Configuration | Wall median, 23 runs | vs baseline | Wall median, 10 runs | CPU median, client + daemon | vs baseline |
|---|---|---|---|---|---|
| baseline | 11.59 s | 11.97 s | 44.4 s | ||
| sinks off | 11.64 s | +0.4% | 10.50 s | 43.5 s | -2.1% |
| all sinks on | 11.26 s | -2.8% | 11.45 s | 46.5 s | +4.6% |
“All sinks on” is the session summary (-vv), the debug port on the client and the daemon, and OTLP
over HTTP on both sides. The OTLP endpoint was a local HTTP server that
answers every request with 200, so serialising and sending are measured and a
collector’s own work is not. Against sinks off, the median wall time with
everything on is 3.3% lower (pooled) and the CPU time 6.8% higher (10 runs).
The extra CPU is the once-a-second sampler, the 22,000 per-file lines and the
exporters, running on otherwise idle cores.
Protocol
The protobuf definitions in
proto/irsync/v1/
(common.proto, control.proto, data.proto, admin.proto, session.proto) are
normative. This page summarises the constants, the streams and the messages;
where it disagrees with the .proto files, they win. The Rust types are
generated from them in the irsync-proto crate.
Networking explains the layers below these
messages, and walks through a real session message by message.
The protocol and the on-disk state (index, session records) change without
compatibility paths until the first release. A client that speaks another
version is refused with VERSION_MISMATCH.
Any change to the wire format bumps PROTOCOL_VERSION
(crates/irsync-proto/src/lib.rs), in the same change: a message or field
added, removed or renumbered, a field’s type changed, an enum value added or
renumbered, or a field’s meaning changed. Two peers of one version always
read each other’s frames the same way. session.proto is not on the wire;
a change to it needs no new version.
Constants
| Item | Value |
|---|---|
| ALPN | irsync/1 |
PROTOCOL_VERSION | 8, carried in Hello.protocol_version |
| Framing | A protobuf varint length (at most 4 bytes for MAX_FRAME), then that many bytes of one protobuf message: protobuf’s standard length-delimited form |
MAX_FRAME | 16 MiB. A longer length is refused before anything is allocated for it. |
| Content hash | BLAKE3, 32 bytes, for chunks and whole files |
| Chunking | FastCDC 2020, normalisation level 1; minimum 64 KiB, average 256 KiB, maximum 1 MiB |
| Chunk list part | At most 32,768 records in a ChunkListStart or ChunkListMore |
| Chunk list | At most 2^24 records. Every chunk but a file’s last is at least 64 KiB; the receiver refuses a list with a shorter one. |
| List room | 2^24 records per connection, across all files |
NeedChunks | At most 2^18 chunk indices and 16 entries of held per message; the sender treats more as a protocol error |
SyncRequest.filters | At most 16,384 rules; a pattern at most 4,096 bytes; all patterns together at most 1 MiB. The daemon refuses a Hello with more. |
Path in PlanItem and CheckLink | At most 64 KiB, and a valid relative path; anything else is a protocol error |
| Chunk basis | Blocks of 512 B to 4 KiB, at most 8,192 blocks; at most 32 MiB of bases held per session |
DataChunk | A piece of one chunk, at most 64 KiB of data; or the operations that rebuild one whole chunk |
| Heartbeat | At most one every 500 ms |
| Hello timeout | The daemon waits 10 s for Hello |
The chunking parameters travel in the handshake (SyncRequest.chunk_min,
chunk_avg, chunk_max); a client with others is refused with
VERSION_MISMATCH. A file’s chunk list and whole-file hash are a pure function
of its bytes and these parameters.
Connection
A client opens one QUIC connection to the daemon’s EndpointId. Before it
accepts any stream, the daemon reads its grants afresh and looks up the
verified key of the client. A key that no grant names, or a configuration that
cannot be read, gets the connection closed with application code 1
(unauthorized) and no message. See
Identity and trust.
Close codes:
| Code | Reason | Client’s response |
|---|---|---|
| 0 | done | None. |
| 1 | unauthorized: the key has no grant | Final. |
| 2 | rejected after an Error, or hello timeout | Final. |
| 3 | superseded: a newer connection resumed this session | Final. |
| 4 | idle: the inactivity watchdog fired | Redial and resume. |
Streams
A session uses two bidirectional streams, both opened by the client, and many unidirectional ones.
- The control stream is the first bidirectional stream. It carries
Helloand theHelloReply, thenControlframes. - The listing stream is the second. The client opens it right after
HelloAckand starts it with aListingStreamHeadernaming the session. Each half then carries one side’s listing asListingFrames: anentry(aFileEntry, withoutdevandinode, which are the lister’s own) per path, in path order; anerror(aPathError) wherever entries are missing (a directory that could not be read, right after its own entry; an entry that could not be stat’ed); oneend(aListingEnd, with the count of entries and anincompleteflag); and the end of the half. A side that does not list, a receiver resuming a complete plan, ends its half without a frame. The listing has its own stream so that a planner that stops taking it, while it waits for files in flight to finish, stalls only the listing and never the frames that finish those files. - Data streams are unidirectional, from sender to receiver, one per run of
contiguous requested chunks of one file, a run being cut at 64 MiB. Each
starts with a
DataStreamHeader(session id, file id, offset, length, index of the first chunk) and carries each chunk’s bytes inDataChunkframes of at most 64 KiB, in order; a frame never runs into the next chunk. The offset is the first chunk’s, or inside it when the receiver already holds that chunk’s first bytes (see Requests, bases and operations). A sender keeps at most--parallelof them open, 128 by default; a daemon that sends always uses 128.
Handshake
The client sends Hello on the control stream: protocol_version, its
build (BuildInfo: package version, short git commit, dirty flag), its
W3C trace context (traceparent and tracestate, empty: no trace; a
daemon that exports traces makes its session span a child of it), and
exactly one request:
| Request | Meaning |
|---|---|
push | A SyncRequest: a session in which the client sends. |
pull | A SyncRequest: a session in which the daemon sends. |
list_exports | No session: the exports this key may use. |
probe | No session: what Probe.path is on the daemon. |
admin | The control stream becomes an admin session. |
The daemon answers with one HelloReply, which holds exactly one of
error (a refusal, then close code 2), ack (a HelloAck, for a push or
a pull), exports (an ExportList), path_info (a PathInfo) or
admin_ready. A Hello without a request is refused with BAD_REQUEST.
Hello.protocol_version and HelloReply.error keep their field numbers in
every version, so a client of another version still reads why it was
refused.
A SyncRequest holds:
session_id: 16 bytes to resume a session, empty for a new one;- the three chunking parameters;
path, the remotePATHas typed, which the daemon resolves (see Remote addresses);contents_only, the trailing-slash rule; and on a push of a source without a trailing slash,name, its basename;single_file: the session copies one file.nameis then the source’s basename on a push, and the name the file gets on the client on a pull; it must be one path component. The daemon treats the directory that holds the file as the session root, so nothing else in it is listed or deleted.--deleteand its relatives are ignored. On a push the daemon decides the file’s name on its side by rsync’s rules and returns it inHelloAck.single_name, which can differ fromname(a file namedT);preserve, the client’s preserve flags (-l -p -t -g -o -D -H -S), which the daemon honours in both directions; it refuses a push or a pull whose request lacks them;recursiveanddirs:-rand-d, which both sides’ listings follow;- the include and exclude rules, compiled and in order. A sending daemon walks with them; a receiving daemon protects what they exclude from deletion;
- the receiver-side options, which the daemon honours only when it receives:
the deletion mode,
--delete-excluded,--max-delete,-n,-u,-c,--inplace,--appendor--append-verify,--partial-dir(relative and inside the destination, or refused),--no-rename-detection(no_rename_detection),--fsync(an export’sfsync = trueflushes whatever the client sent).-i,--ignore-errorsand--numeric-idsapply in both directions; paranoid:--paranoid. Both roles take part in the final re-check, which the receiver asks for withSettle, so a daemon honours it in both directions. Only the sending side clones or hashes each file again, so on a push the daemon does neither;bwlimit:--bwlimitin bytes per second. The side that sends the file data paces it, so the daemon honours it only when it sends (a pull); on a push the client paces itself. Absent or 0 means no limit.
A push or a pull is answered with ack: a HelloAck with the session id,
whether the session was resumed, the daemon’s BuildInfo and, on a
single-file push, single_name. Each side logs the
other’s build at info level once the session is up.
list_exports is answered with exports: the exports this key may use with
their paths and effective access, sorted by name. The daemon then closes the
connection.
A probe opens no session. The daemon resolves Probe.path as it would
for a pull, applies the same access checks, and answers with path_info,
whose kind is MISSING, DIRECTORY or FILE (anything that is not a
directory, a symlink included), then closes. A client uses it to learn
whether a pull without a trailing slash names a file.
An admin request turns the control stream into an admin session, defined
in admin.proto. A key without admin gets an error with
UNAUTHORIZED and the message not allowed. Otherwise the daemon answers
with admin_ready; the client then sends AdminRequest frames and the
daemon answers each with an AdminReply:
| Message | Direction | Meaning |
|---|---|---|
Change | client to daemon | One change: an export, grant or client add, remove, rename or set. Held, not applied. No reply. |
Commit | client to daemon | Apply the held changes, all or nothing: answered with Ack (one result line per change) or Nack. At most 100 changes; a session idle for 10 minutes is closed. |
Read | client to daemon | ReadView for the exports, clients and daemon facts, or ReadConfig for one key (empty: every key). Answered with View or ConfigText, from the saved config. Needs admin ro or rw. |
Nack | daemon to client | Nothing was applied. change is the 1-based number of the change at fault, or 0 for the whole transaction (busy, not allowed, own admin right, too many changes). |
A request the daemon refuses inside the session (one it cannot read, a read
of a key that does not exist, a request too large) gets an AdminReply
whose refused holds the Error.
Errors
An Error is a code and a message. It refuses a Hello (in
HelloReply), refuses an admin request (in AdminReply), or, as the
error of a Control frame, ends a session that failed: either side may
send that one, with INTERNAL.
| Code | Sent when |
|---|---|
UNSPECIFIED | Never sent. |
UNAUTHORIZED | The key has grants, but none for an export that contains the path. The message is no access to PATH. |
READ_ONLY | A push to an export that is read_only or that this key may only read. |
BAD_PATH | The path has a .. component or a NUL byte, or the session’s root cannot be prepared. |
VERSION_MISMATCH | Another protocol version or other chunking parameters. |
BAD_SESSION | A resume of a session the daemon does not know, that is finished, or that another key started. The client starts a fresh session at once. |
INTERNAL | The daemon failed, for example opening the export’s index; or a session failed (in Control). |
BAD_REQUEST | A malformed request: a Hello without a request, rules over the limits, an admin request that cannot be read. |
The answer for a path a key may not use is the
same whether the path lies outside every export, inside an export without a
grant, or does not exist at all, so a key cannot probe the daemon’s layout.
READ_ONLY and a BAD_PATH about the root go only to a key that may use the
export.
Control messages
| Message | Direction | Meaning |
|---|---|---|
PlanItem | receiver to sender | Send this file: WHOLE (nothing to reuse at that path), DELTA (the receiver holds an old version) or APPEND (the receiver trusts its first append_from bytes). |
ChunkListStart | sender to receiver | The start of a file’s chunk list: its total record count, the whole-file hash, the first records, and the stat the file was hashed under (SourceStat: size, mtime, change time, inode, mode, uid and gid, with the names of the owner and group). The receiver places the file with the size, mtime, mode, owner and group instead of the walk’s. The change time and inode are for the link check (CheckLink). |
ChunkListMore | sender to receiver | The next records of a file’s chunk list. |
WithdrawChunkList | sender to receiver | Drop the file’s chunk list and free its room: a new list follows. |
ListRoom | receiver to sender | Room for this many more chunk records, freed by lists the receiver dropped. |
ChunkBasis | receiver to sender | Block signatures over a region of the receiver’s old file, for one chunk. |
NeedChunks | receiver to sender | The chunks to send; empty means none. |
MayPlace | receiver to sender | The file is verified against chunk list number gen; may it be placed? |
PlaceVerdict | sender to receiver | The answer: changed if the source differs from the stat it was hashed under. The receiver places the file only when it is unchanged; otherwise it drops it and waits for the new chunk list, or for a SourceError. A MayPlace about a list older than the sender’s latest is always answered changed. |
FileAck | receiver to sender | How the file ended: DONE, HASH_MISMATCH or WRITE_ERROR (UNSPECIFIED is never sent; the sender takes it as a protocol error). DONE carries the bytes the receiver did not take from the sender. |
SourceError | sender to receiver | The sender cannot read the file, and says why. The receiver drops it without a reply. |
Itemized | receiver to sender | One rsync -i line, for a client that pushes with -i. |
Heartbeat | either | This side is busy; see below. |
Settle | receiver to sender | With --paranoid (not on a dry run), once, in place of the first SessionDone: every path is planned and no file is in flight. The sender stats every file it listed again. |
Replan | sender to receiver | After Settle: a listed file that changed since it was listed or last hashed: its entry as it is now, path included. The receiver plans it again, under a new file id. |
Settled | sender to receiver | The re-check is over: the listed files that vanished, and those it could not stat. The receiver sends SessionDone once the re-planned files are done. |
CheckLink | receiver to sender | With -H (not on a dry run), once every path is planned, no file is in flight and the re-check (if any) is over: one per hard link about to be made to a file sent in this session, on this connection or an earlier one. It carries the name and the stat its target was hashed under. |
CheckLinksEnd | receiver to sender | The last CheckLink has been sent. With -H it is always sent, even with no links to check, before SessionDone. |
Unlinked | sender to receiver | A name that is no longer exactly the file its target was hashed as: its stat differs (inode, size, times, mode, owner or group), or it is gone or no longer a regular file the walk would list. The receiver does not link it. If it is still a regular file, entry holds it as it is now, and the receiver plans it as a file of its own, as for Replan. Otherwise failed holds the name, which fails. |
LinksChecked | sender to receiver | The link check is over. The receiver makes the other links, then sends SessionDone. |
SessionDone | receiver to sender | The session’s totals (files_placed, placed_size, bytes_received, created), errors and deletions (deleted_paths, would_delete_paths, capped, with counts of the rest), and what the sender’s listing held (listed): a sender that resumed from the receiver’s stored plan listed nothing itself and reports these counts. |
Error | either | The session failed on this side, with INTERNAL and why; it ends the session. |
Every message on the control stream is a Control frame with exactly one of
these set. A file costs a PlanItem, a ChunkListStart (and
ChunkListMores for a long list), a NeedChunks, a MayPlace, a
PlaceVerdict and a FileAck; the room its list took comes back in a
ListRoom, which may cover several files.
Chunk lists
A chunk list travels as one ChunkListStart and then ChunkListMore
frames, in order, each with at most 32,768 records; an empty file’s list is
one ChunkListStart without records. The start carries the file id, the
total record count, the whole-file hash and the stat the file was hashed
under; each ChunkListMore carries the file id and the index of its first
record. A ChunkRecord is a length and a hash: its offset is the sum of the
lengths before it, from 0, or from append_from for an APPEND tail. The
list is complete once total records have come. The receiver
reassembles them and fails the file when a sequence skips or announces more
records than 2^24 or than the size allows at the minimum chunk length. The
stat (SourceStat) is the size, mtime, change time, inode, mode, uid and
gid, and the start also holds the names of the uid and gid on the sender.
These replace the walk’s for the file, and the names are mapped to the
receiver’s ids as for a listing entry (not with --numeric-ids). An
APPEND tail’s list carries the whole file’s stat.
Lists travel in room the receiver grants. Each connection starts with room for
2^24 records on both sides; a list’s start takes its whole total of it,
and a sender sends a list only once it fits. The receiver gives room back with
ListRoom when it drops a list: the file was placed, failed or replaced. A
start that does not fit, or a grant above the starting room, is a
protocol error. A start for a file that already has a list replaces that
list; a sender that lists a file again first sends a WithdrawChunkList,
so the old list is dropped without waiting for room.
For an APPEND, the list covers only the tail from append_from and carries
no whole-file hash; the receiver folds the hash from the bytes it places. Every
other list carries one.
Requests, bases and operations
NeedChunks names chunk indices; a request for more than 2^18 comes as
several, which the sender treats as one. Before the NeedChunks that names a
chunk of a DELTA file, the receiver may send a ChunkBasis for it: a region
of its old file named by its offset there, cut into blocks of 512 B to 4 KiB,
and per block a 32-bit rolling sum and the first 8 bytes of the block’s BLAKE3
hash. The control stream is ordered, so a basis precedes the request that uses
it. The sender keeps a basis for that one request and drops it; a chunk asked
for again comes raw. A malformed basis is ignored. A sender that holds more
than 32 MiB of bases fails the session.
NeedChunks.held names chunks of the request whose first bytes the
receiver already holds, with how many: the pieces an earlier connection
delivered before it dropped, at most 16 chunks per file. The sender starts
such a chunk’s data there, raw, in a stream of its own whose offset is
inside the chunk. The receiver writes each piece into the .part as it
arrives and verifies the chunk against its hash once it is whole; a chunk
that fails is asked for again from its start. The receiver sends no basis for
a chunk it holds bytes of. In place (--inplace) it holds none: only
verified chunks reach the file there.
A chunk with a basis may arrive as DataChunk.ops instead of data: a list
of literals and copies (offset, len in the receiver’s old file) that add up
to the chunk. The sender uses operations only when they are at least a quarter
smaller than the chunk. A copy must be a run of whole blocks of the basis the
receiver sent for that chunk: it starts on a block of the region and its length
is a multiple of the block length. The receiver refuses any other copy, and any
operations for a chunk it sent no basis for, and asks for the chunk again
without a basis. This keeps a sender from finding out what the old file holds
by asking for single bytes of it. The receiver rebuilds the chunk and verifies
it against the chunk’s hash like any other. How the receiver chooses and uses bases is in
Receiving a changed file.
Heartbeats
A Heartbeat means “I am busy”. A side sends one every 500 ms in which it made
progress: hashing, writing, finalizing, deleting, or traffic. It carries what
the other side cannot otherwise see: the directory this side’s walk is in,
the bytes its planner found up to date, and its deletion count (deleted_count). An idle side sends none,
so a stuck side still times out. The receiver sends none after SessionDone,
which is the last message on its control stream. A receiver that resumes its stored plan sends
one extra Heartbeat before its first request, with listed, the totals of
the sender’s listing on the first connection, and listed_settled, how many of
those bytes need nothing more: files found up to date or already placed.
Nothing is listed again, and the sender shows its progress from these. See
Sessions and resume.
Persisted state
session.proto describes what each side stores in its index for a session
that may resume: the plan (SessionPlan, with PlanEntry per file) and the
progress (SessionProgress). These messages never go on the wire. Partial
files are stored as PartialRanges (of Ranges): the verified bytes, and the
first bytes of chunks that did not finish (held); a RangeSet is the
verified bytes alone. See
Sessions and resume.
Cross-implementation check
crates/irsync-proto/tests/golden/chunk_1mib.json is a golden vector: the
whole-file hash and the exact chunk boundaries (offset, length, BLAKE3 hash)
of 1 MiB from the xorshift64 generator seeded with 0x9E3779B97F4A7C15 (see
crates/irsync-proto/tests/chunk.rs). An independent implementation must
reproduce it exactly to interoperate, because chunk boundaries decide which
chunks a client and a daemon consider equal.
crates/irsync-proto/tests/golden_bytes.rs pins PROTOCOL_VERSION and the
exact wire bytes of several messages, so a change of field number or wire
type shows, and with it a version that was not bumped.
Known limitations
- Idle connections are dropped. The daemon drops an authenticated
connection that has had no traffic and no local progress, such as hashing or
writing, for
idle_timeout, 30 minutes by default. The client reconnects and resumes. See Configuration. - Only file-based Ed25519 keys. Hardware keys and ssh-agent keys cannot be
used. Of the keys under
~/.ssh, onlyid_ed25519is tried, unless[defaults] identityin the config file or--identitynames another. See Configuration. - Relays are slow. The throughput target, filling a 1 Gbit/s link, applies
to direct connections. Relays are a fallback and are much slower. When one
end sits behind a symmetric NAT and the other behind a symmetric or
port-restricted NAT, hole punching fails and the connection stays on the
relay; then run a self-hosted relay and point
relayin[defaults]and[daemon]at it. Configuration has the keys, and Connections explains relays. - No compression.
irsynchas no counterpart to rsync’s-z; data crosses the link as it is stored. - Several sources with
--deletecan delete what an earlier source copied. Each source is its own session, one after the other. Inirsync --delete a.iso photos/ myserver:T/, thephotos/session deletes theT/a.isothat was just copied. rsync merges the sources into one list and does not. The same happens witha/ b/. - Linux and macOS only, on x86_64 and aarch64, as client and as daemon.
- No extended attributes or ACLs.
irsynccopies neither; see rsync options irsync does not have.
rsync options irsync does not have
irsync rejects these with exit code 2. The list is not every rsync option,
only those an rsync user is likely to reach for.
| rsync option | In irsync |
|---|---|
-X, --xattrs | Extended attributes are not copied. |
-A, --acls | ACLs are not copied. |
-x, --one-file-system | The walk does not stop at filesystem boundaries. |
-R, --relative | Paths are relative to the source operand; a trailing / copies a directory’s contents. |
--files-from | Select files with --include and --exclude. |
--link-dest, --compare-dest | No hard-link or comparison directories. Chunks of any file the receiver’s index knows are reused. |
--backup | Replaced and deleted files are not kept. |
-e | The transport is always iroh QUIC. irsync pair --rsh names the ssh command, but only for setting the server up, never for the data. |
-W, --whole-file | No switch to turn the delta off. |
-z, --compress | No compression. |
-L, --copy-links | Symlinks are copied as symlinks with -l, or skipped. |
--partial | Partial files are kept and resumed without a flag; --partial-dir moves them. -P is accepted, as --progress. |
--size-only, --ignore-existing, --existing, --remove-source-files, --chmod | Not available. |
How we verify irsync’s correctness
For a sync tool, correctness comes first and speed second. This page states what irsync claims, what backs each part of the claim, how you can check it yourself, and where the claim stops.
The claim
A completed
-a --deletesync of a source that is not changing leaves the destination exactly matching the source.
Each condition matters:
- Completed means the run ended with exit code 0. A run that was interrupted, or that ended with exit 23 (some files failed), is not complete. See Outside the claim.
-akeeps permissions, times, symlinks, devices and special files.--deleteremoves destination files that are gone from the source.- Not changing means nothing writes to the source while the sync runs. Files that change during a sync says what happens otherwise.
“Exactly” covers the items below. The last column says what checks each one. fileset is a separate checking tool, described in the next section.
| Item | Kept by | Checked by |
|---|---|---|
| Names, and which entries exist | any sync; --delete removes extras | fileset’s default check (ADD, DEL) |
| Type (file, directory, symlink, device, FIFO) | -a | fileset’s default check |
| File contents | any sync | fileset’s default check; irsync also checks every chunk and the whole file with BLAKE3 |
| Permissions and modification times | -a | fileset’s default check |
| Symlink targets | -a | fileset’s default check |
| Device numbers | -a | fileset’s default check |
| Hard links | -H, which -a does not include (as in rsync) | fileset with --require nlink or --paranoid only |
| Holes in sparse files | files sparse in the source are written sparse (see -S in the command line) | the engine test sparse_file_stays_sparse and the sparse campaign row (which runs with -S) only; fileset does not record holes |
| Deletions | --delete | fileset’s default check (ADD for anything left behind) |
So for hard links, the full command is -aH --delete. That is what the test
loops run.
Some things irsync does not carry at all, such as extended attributes and
ACLs. Owners are kept only when the receiving side runs as root (see -o in
the command line), and sockets are never
copied. These edges are listed in Known limitations.
Check it yourself with fileset
You do not have to take the claim on trust. fileset is a second line of defence: it records a manifest of a tree (each file’s checksum and metadata), and later checks a copy against it. It is a separate tool that shares none of irsync’s code, so a mistake in how irsync syncs does not repeat in the check. It is also the same check the test loops below run after each sync.
Record a manifest on the client, sync, then check the copy on the server:
fileset init ~/Photos
irsync -a --delete ~/Photos/ myserver:photos/
fileset check /srv/photos # run this on myserver
The default check compares type, content, symlink target, device numbers, permissions, modification time and size. Widen it when you need to:
--require nlinkadds the link count, so a hard link that arrived as a separate copy shows up.--paranoidadds it too, along with owner, group and extended attributes.- fileset does not record holes in sparse files. A sparse file and a fully written copy of it pass every tier.
Verify an irsync transfer walks through the
same check step by step (with -av and without --delete). The fileset reference
lists every field each tier compares.
How we check it, layer by layer
The tests run from fast and narrow to slow and broad.
Engine tests. The tests in crates/irsync/tests/ run two irsync engines
in one process and sync real trees between them. A test build adds hooks
that record the order of internal steps, so a test can pin, for example,
that a file changed while it was sent is sent again, or that a stale local
chunk is fetched over the network instead. See
Testing.
The stress loop. irsync-stress runs a loop on one machine: a
generator of random file changes (filegen, a tool for contributors) changes
the source, fileset records it, irsync syncs with -aH --delete, and fileset
checks the destination. It repeats for many iterations, so each sync starts
from the last one’s result. See Stress testing.
The same loop over a bad network. irsync-netstress runs that loop with
every packet passing through a simulated link: limited speed, delay, bursts
of loss, and dead zones that cut the link and force a reconnect and resume.
See Network stress with netstress.
Writing to the source during the sync. Both stress tools have a
--concurrent mode in which the generator keeps changing the source while
irsync syncs it. Each destination file is then judged against every state
the source held, content and metadata, and a second sync with nothing
writing must leave an exact copy. The aim: no destination file is ever a
state the source never held. A self-test with the change checks switched off
proves the judge catches torn files. See
Writing during the sync.
Campaigns. Long runs over many random seeds, each aimed at one area:
hard links, renames, sparse files, metadata, timestamps, symlinks,
deletion, long names, and more. After a run the destination is also
checked with --paranoid, and with du -s for sparse files. See
the campaign matrix.
The evidence
The loops find real bugs, not just pass. Among them: file names near the length limit that could not be transferred, and metadata applied to a hard link reaching names the source had unlinked. Each is fixed and has a regression test. The list is in Bugs the harness has found.
Outside the claim
The claim does not cover these cases.
- A sync without
-adoes not keep permissions and times. - A sync without
--deleteleaves files that are gone from the source in place. - An interrupted sync, or one that ends with exit 23, is incomplete. It
may leave
.irsync.<name>.partfiles behind. Running the same command again resumes it. - A power cut soon after a sync. By default irsync does not flush files to
disk before it renames them into place (
--fsyncis off, as in rsync). After a power cut or a kernel crash in the seconds after a run, a file can keep its name, size and time but lose its content. The next run’s quick check does not notice;-cdoes. See--fsyncin the command line. - Files that change during the sync. See the next section.
Files that change during a sync
irsync first lists the source, then reads each file that needs sending to compute its hash (a checksum of each chunk and of the whole file), then sends the chunks. Here is what happens when a file changes along the way.
-
A change while irsync hashes the file. When the pass is done, the sender checks the open file again: its size, modification time, change time and inode must be what they were when the pass began. If not, the hash may describe a mix of old and new content, so the file is hashed again. The error text is “changed while it was hashed”.
-
A change after hashing. Before the receiver puts a verified file in place, it asks the sender. The sender looks at the source again and compares it with the stat its hash was taken under. A difference gives “changed after it was hashed”. This also catches a change only in chunks the destination takes from its own copy, which the sender never reads again.
-
A change in a chunk irsync sends. Before a chunk leaves the sender, irsync reads it again and checks it against the hash.
-
One retry, then exit 23. Every check above shares one retry per file. If the file changes again, it is given up with an error that ends in “(after retry)”, the other files carry on, and the run exits 23. The destination keeps its old copy. With
--inplaceand--appendthere is no old copy to keep: they write into the destination file itself, so it already holds the written data when the change is found. The run still exits 23. -
Deleted after it was listed. If irsync still had to read it, the file fails, the run ends with exit 23, and the destination keeps its old copy. Otherwise it is not noticed in this run; the next run with
--deleteremoves it. -
Created after the listing. It is not sent in this run.
-
A hard-link name that changes, with
-H. irsync groups the names of a file when it lists the source, and sends the file once, under its first name. Just before it makes the other names links to the copy, the receiver asks the sender to look at each name again. A name that is no longer exactly the file that was hashed is not linked. A name replaced by a file of its own is sent as that file, in the same run, with its retry already used. A name that is gone fails, and the run exits 23. A name whose first name was not sent, because the destination was up to date, is linked as listed: both names held that content when irsync listed them.
These checks compare size, modification time, change time, inode, permissions, owner and group. Programs can reset the modification time, but nothing can set the change time back.
A sent file is placed with the size, modification time, permissions, owner
and group it had when its hash was taken, not the ones the listing saw. So a
chmod, or another file saved over it, between the listing and the hash
cannot leave new content with old permissions: content and metadata always
come from the same moment.
Because they compare the change time, a change to a file’s metadata alone
during the sync counts as a change, even though its content is the same:
chmod or chown, extended attributes set by an indexer or a virus
scanner, or a new hard link made by a snapshot tool. The file is retried,
and the run exits 23 if it happens again.
With --paranoid
--paranoid closes the gaps the checks above leave.
- Clones. Before hashing a file, irsync makes a reflink clone of it: a
copy that shares the file’s disk blocks and never changes afterwards. It
hashes and sends the clone. The destination then gets a state the source
really held, whatever the source does meanwhile. A clone is accepted even
if the source changes after it was made; irsync logs a note. Cloning works
on btrfs, xfs, ZFS 2.2 and newer with block cloning, and bcachefs on Linux,
and on APFS on macOS (not yet tested). Clones live in
.irsync-clones-<uid>/<session>/, mode 0700, in the highest directory on the file’s filesystem that you can write to. Directories that group or others can write to, without the sticky bit, are skipped. irsync removes the clones when the run ends. Clones a crash left are removed by a later--paranoidrun that clones on that filesystem. The scan skips these folders. Each file in flight keeps its clone open; if irsync runs out of file descriptors, that file is hashed a second time instead of cloned. - Without clones. Where the filesystem cannot clone, irsync hashes the file a second time before the receiver places it and compares the whole digests. A difference gives “changed after it was sent”.
- A final re-check. At the end of the run, irsync looks at every file it listed once more. A file that changed is sent again, from a clone where possible. A file that is gone, or no longer a regular file, does not fail the run, but it ends with exit 24, “some source files vanished”. A file irsync cannot read gives exit 23. When several codes apply, 1 wins over 25, 25 over 23, and 23 over 24.
- On a pull,
--paranoidtravels to the daemon, which does the sending and so runs all of this.
Memory-mapped writers: a program can write into a file through a memory
mapping, and the file’s times do not change until the system writes the pages
out. In a test on ZFS 2.4 (clone_includes_unflushed_mmap_writes), a clone
made right after such a write held the new bytes. So on that filesystem a
clone includes memory-mapped writes that have not reached the disk. Other
filesystems have not been tested. Where irsync cannot clone, the second hash
reads the file as the system holds it. Whether that includes them has not
been tested.
Costs. On a filesystem that clones, --paranoid makes one clone and
deletes one per sent file. Elsewhere it reads each sent file one more time.
At the end it makes one stat per listed file. It also creates and removes
the clone folder, which changes the modification time of the directory that
holds it, on each run. Under --paranoid, the final re-check treats a
changed mode or modification time as a change, because the stat differs. The
file is then sent again in full as a delta, which reads both sides, even
though its content is unchanged.
Limits
- Memory-mapped writers, without
--paranoid. The checks cannot see a write through a mapping before its times change.--paranoidmay help; only clones on ZFS 2.4 are shown to include such writes (see the memory-mapped note above). - Coarse timestamps. Fine-grained change times exist on ext4, xfs, btrfs and tmpfs on Linux 6.13 and newer. Elsewhere (older kernels, other local filesystems such as ZFS, network filesystems, FAT) assume coarse timestamps: a write in the same tick as the first stat can slip through the stat checks.
- Files that change after the listing but are not sent. Without
--paranoid, irsync does not look at them again. The destination keeps the version from the time of the listing, a state the source really held. The next run sends the new one. - Resumed
--paranoidruns. A resumed run re-checks only the files it sent itself. If the connection drops after the re-check and before the session ends, the list of vanished files can be lost, and the resumed run can exit 0 where the first would have exited 24. - A re-sent file has no retry left. A file sent again by the final re-check starts with its retry used, so a transient mismatch fails it at once. Its hard-link names at the destination are linked to the new copy.
- Hard-link names, with
-H. The final re-check stats only the main name of each group of hard-linked files. The link check that follows it looks at the other names again, but only those of files sent in this run. If such a name is deleted at the source, it fails rather than counting as vanished: the run exits 23 instead of 24. - Bind mounts share one device number, and cloning across them fails
with
EXDEV, so that filesystem falls back to the second hash. - A umask of 002 makes new directories group-writable, which may leave no safe place for the clone folder. irsync then uses the second hash.
What to do:
- Where the source is written while you sync,
--paranoidhelps, within the tested limits above. - Better still, sync from a snapshot.
- Run the sync again once the writes have stopped, or run it with
-c, which compares contents instead of size and time. - Check the result with fileset.
What the tests cannot see
Every bug the test loops find has to pass three filters:
- The generator must provoke it. A change the generator never makes is never tested.
- fileset must observe it. The loops run fileset’s default check, which does not compare hard links, owners or extended attributes, and does not record holes. Campaigns widen this after a run.
- A known bug must not hide it. A bug that fails every iteration hides anything else underneath it.
Hunting bugs has the detail.
For contributors
Testing says which test to add or run for each kind of change.
Sessions and resume
A sync in irsync is a session, not a connection. The session is the job: the
plan of which files to send and how far each one got. A connection is only the
current way of moving it forward. When the connection drops, the session
waits; when the process dies, the session stays on disk; the next connection,
or the next run of the same command, continues it. This page explains what a
session holds, how it is found again, and what a resumed session skips.
What a session is
A session has a random 128-bit id, which the daemon assigns in its HelloAck,
a plan and a record of progress. Both sides keep the plan and the progress in
the index of the root they work on, under state_dir (see
Files and state), and write
them at most every 2 seconds and once more at the end:
- the plan: each file the receiver decided to request, with its action, size, hash and listing entry, and once the listing is over, a flag that the plan is complete, with the directories and the errors found on the way;
- the progress: the files acknowledged as done, the bytes transferred over all
connections, and the deletions so far, which count against
--max-delete.
Separately from the session, the receiver records for each partly received
file which byte ranges of its .part file it has verified, and how far it got
into chunks that did not finish. That record is written after every 64 newly
verified chunks or every 2 seconds, when the connection drops, and belongs to
the file, not to the session. The exact messages are in
Protocol.
A finished session’s record is deleted.
When the connection drops
The client dials again and sends Hello with the same session id. Both sides
load what they stored and carry on. A file acknowledged as done is not touched
again. A file that was partly received continues from its verified chunks: the
receiver reads each recorded chunk of the .part back, checks it against its
hash, and requests only the rest. Chunks that were written but not yet
recorded are requested again.
A chunk is up to 1 MiB, and it travels in pieces of 64 KiB. The receiver
writes each piece into the .part as it arrives, so a chunk that was cut off
continues after its last piece: the request says how many of its bytes the
receiver holds, and the sender sends only the rest. Once the chunk is whole,
the receiver checks it against its hash; if the check fails, it asks for the
whole chunk again. So a link that drops before a whole chunk crosses still
moves the file forward, one connection at a time.
The client redials with exponential backoff: 1 second, doubling up to 60
seconds, plus up to a quarter of random jitter, so that many clients do not
redial in step. It keeps going for --reconnect, 24 hours by default, measured
from the first dropped connection since the session last made progress: however
long a connection worked before it dropped, the client dials again at least
once. A connection that the daemon
accepts but that moves no data and places no file does not count as progress,
so a daemon that accepts and drops every connection cannot keep a client
retrying forever. --reconnect 0 gives up at once, as rsync does.
Some answers end the session instead of a retry: an Error from the daemon
(the key may not use the path, the export is read-only, another protocol
version), and close codes 1 to 3 (see
Protocol). A daemon that no longer knows
the session answers BAD_SESSION, and the client starts a fresh session at
once.
When the process dies
The client stores the session under a key derived from what the command means,
not how it was typed: the daemon’s EndpointId (so a server name and the raw id
are the same), both locations (a local one by its canonical path, a remote one
as typed, each with its trailing-slash rule),
the preserve flags, -c, -u, --inplace, --append or --append-verify,
the deletion mode with --delete-excluded, -n, and the filter rules in order.
Flags that do not change the result, such as --parallel, --bwlimit or
-v, are not part of the key.
The next run of the same command computes the same key, finds the stored
session and prints resuming session <id> from <time>, with the first eight
hex digits of the id and the time of the last write. A command that differs in
any part of the key starts its own session. There is one stored session per
key: a new one replaces an old one.
--no-resume ignores the stored session and plans afresh. Partly received
files are still picked up, since their records belong to the files: a .part
whose record names the same expected size and hash continues from its verified
chunks.
What the daemon checks
The daemon keys its copy of the session by the client’s EndpointId, the
export and the path inside it as resolved, the direction, the trailing-slash
rule, and the receiver-side options. A resume must match all of them.
Only the key that started a session may resume it. A Hello with the id of a
session that another key started, that is finished, or that the daemon has
collected, gets BAD_SESSION, with no hint which of these it was.
When a second connection resumes a session that an older connection still holds, as when the same command runs twice at once, the daemon closes the older one as superseded, waits for it to let go, and continues with the newer. The older client stops with an error rather than taking the session back.
What a resumed session skips
On a resume with a complete plan, neither side lists again: the receiver recreates the planned directories where they are missing and requests the files not yet done, and nothing else. This is what makes a resume after an interruption cheap for a large tree. Two cases list afresh even then: a run with deletions, because the stored plan holds no deletion candidates, and a dry run, which stores nothing worth resuming. They still skip the files the progress marks as done.
A resume with an incomplete plan lists both sides again and plans the files that are not done yet, using the index to skip unchanged ones.
How long a session waits
A session that nobody resumes is dormant. Garbage collection removes dormant
sessions and their partial files after dormant_session_timeout, 7 days by
default, on the daemon, and after 7 days on the client. A partial file that a
stored session still plans to write is kept. When collection runs is in
Clean up state.
The daemon also limits how many dormant sessions one client key may leave in
an export: max_dormant_sessions_per_key, 25 by default. Each time a session
of that key ends, the daemon counts the key’s dormant sessions in that export
and drops the ones that went longest without progress until the limit holds.
A session that a connection is using is never dropped and does not count. A
client that comes back for a dropped session gets BAD_SESSION and plans
afresh. The partial files stay, so that run still continues the files it had
begun. The client has no such limit for its own records.
Timeouts
Three timers decide when a connection is given up on, and each leads to a redial, not to the end of the session:
- QUIC’s idle timeout, 60 seconds, with keep-alives every 5 seconds: the path is gone. See Connections.
- The daemon’s
idle_timeout, 30 minutes by default: nothing has happened on the session for that long. - The client’s
--idle-timeout, oridle_timeoutunder[defaults], off by default: no control message, no data and no local progress for that long. It also bounds the wait for the daemon’s reply toHello.
Local progress (hashing, writing, finalizing, deleting) counts as activity, so
that a side busy with a large file does not look dead. The busy side tells the
other with a Heartbeat every 500 ms in which it made progress; an idle side
sends none. Since heartbeats come every half second, an --idle-timeout below a few
seconds is unreliable.
Identity and trust
irsync has no passwords, no user accounts and no certificate authority. Each
client and each daemon is an Ed25519 key pair, and its EndpointId is the
public half. Who may connect is a list of EndpointIds on the daemon; whom a
client connects to is the EndpointId it dials. This page explains where the
keys come from, why the client trusts nothing it has not been given, and how
the daemon decides what a key may reach. The Threat model
says what all of this does and does not defend against.
Keys and EndpointIds
A key is an OpenSSH Ed25519 private key file. The EndpointId is the 32-byte
public key, printed in hex or z-base-32. iroh’s QUIC handshake proves that each
end holds the private key for the EndpointId it presents, so the client knows
it reached the daemon it dialled, and the daemon knows which key connected,
before any irsync message is exchanged.
The client and the daemon use different keys, so both can run in one account on one machine and reach each other:
- The client’s key is looked up the way ssh picks one, ending with
~/.ssh/id_ed25519if it exists and with a newly generated~/.config/irsync/id_ed25519if nothing else serves. The order is in Configuration. - The daemon’s key is
[daemon] identity,~/.config/irsync/daemon_ed25519by default, generated the first time the daemon,irsync export addorirsync showneeds it.
A key is the identity for good. Replacing it with irsync id generate --force
gives the machine a new EndpointId: every grant made for the old one stops
matching, and every client that pinned the old daemon id fails to connect.
Only file-based keys work; see
Known limitations.
The client pins the daemon
A remote is named by its EndpointId, or by a server name that stores one. The
client dials that key and nothing else. A daemon with another key fails the
connection; it is not a warning to confirm.
There is no trust on first use. The client never learns a daemon’s key from
the network, has no known_hosts file to add to, and never asks whether to
trust a key it has not seen. Each id travels once, in its own direction: the
client’s id to the daemon’s machine, for the client entry, and the daemon’s id
to the client, for the server entry. irsync pair carries both over ssh, a
login you already trust; set up by hand, you copy them yourself, as in
Your first sync. In exchange, nothing on the way can redirect a client: a DNS or DHT
record, a relay or an address given by hand only says where to knock, and a
wrong one leads to a failed connection, never to the wrong daemon (see
Connections).
The daemon checks grants
A grant names a key and an export, read-write or read-only. Grants live in the
daemon’s configuration, under each [exports.NAME], as client names or raw
EndpointIds. A client entry can also hold all_exports for every hand-made
export and all_paths for any path. irsync client set writes them.
irsync grant add also takes a pasted ssh-ed25519 line or a .pub file and
writes the id it holds. A grant that
names a client follows the client: pointing myclient at a new id with
irsync client add moves every grant that names myclient.
The daemon reads its configuration afresh for every connection, once the handshake has proved the client’s key, and checks the key against it before it accepts any stream:
- A key that has no grant and no right (
all_exports,all_pathsoradmin) is closed on at once, with no message. There is no open access:alland*are refused as a grantee. - A configuration that cannot be read rejects the connection; the daemon does not fall back to an earlier copy.
- A change to the grants applies from the next connection; a session in progress keeps running. See Change exports and settings.
Access combines in a fixed way. A key’s entry in an export’s own table decides
its access there; without one, its client’s all_exports does, so an export’s ro
entry limits a key whose all_exports is "rw". Within one table, rw wins over
ro. An export marked read_only, which irsync export add --read-only sets,
refuses pushes from everyone, whatever they are granted. The rules are listed
in Configuration.
Paths, exports and “no access”
A remote path is resolved on the daemon’s machine, as an export name, a path under the daemon account’s home, or an absolute path (see Remote addresses). Then the export that contains it is chosen, among the exports the key has a grant for only. Exports may be nested:
- The most specific export, the one with the longest path, decides the session’s root and access. Between exports with the same path, the one the operand named wins, then the one with the better access.
- A grant on an outer export reaches everything below it, the inner exports
included. An inner export the key has no grant for does not stop it, and
neither does an inner
read_onlyexport, since an export without a grant takes no part in the choice.
A path that no export the key may use contains is refused with
no access to PATH. The answer is the same whether the path lies outside
every export, inside an export without a grant, or does not exist, so a key
cannot learn the daemon’s layout by probing. Only a key that may use the
export learns more: that the export is read-only, or that the path cannot be
used as a session root.
A .. component or a NUL byte is refused in every path, before any lookup.
Below the export’s directory, every existing component of the session’s root must
be a directory and not a symlink to one, so the root cannot leave its export
either.
Sessions belong to their key
A session is resumed only by the key that started it. A Hello that names the
session id of another key gets BAD_SESSION, the same answer as for an id the
daemon never knew. See
Sessions and resume.
Threat model
This page says who can send irsync data, what each of them could try, what stops them, and what irsync does not defend against. It is the map for anyone who wants to judge whether irsync is safe for their use, or who wants to look for holes.
Identity and trust explains the keys and grants in detail. This page builds on it.
What irsync sets out to protect
- Data on the way. Nobody between the client and the daemon can read or change it.
- Who you talk to. A client reaches the daemon whose key it named, or nobody.
- Who gets in. A key reaches only the exports it has a grant for, and only in the way the grant allows: reading, or reading and writing.
- Everything outside the sync. A sync changes files only inside its destination directory. A daemon reads and writes only inside the export.
- Content. What is placed in the destination is what the source had. How we verify irsync’s correctness covers this one.
Who can send irsync data
| Who | What they control | How far they are trusted |
|---|---|---|
| The network, relays and address lookups | Packets, and the answers to “where is this daemon” | Not at all |
| A key without a grant | A connection attempt | Not at all |
| A client with a read-only grant | Requests for files in an export | To read that export |
| A client with a read-write grant | File names, contents and metadata pushed into an export | To change that export, and nothing else |
A client with all_paths = "rw" | The same, for any path | As much as the daemon’s account itself |
A client with admin = "rw" | Changes to the exports, clients and grants | To change who may reach what on this server, and so to give itself any path |
| The daemon a client talks to | The listing and the data on a pull; the answers on a push | To hold the files you give it, and to supply the files you ask for |
| Whoever made a tree you sync | File names, symlinks, permissions, and any .fileset manifest in it | Not at all, beyond the content you chose to copy |
| Other users of the same machine | Files in directories they can write | Not at all |
The sections below take them in turn.
The network, relays and lookups
What they could try: read the data, change it, pretend to be the daemon, or send the client to another machine.
What stops them:
- Every connection is QUIC with TLS, between two Ed25519 keys. The handshake proves each end holds its private key before any irsync message is sent.
- The connection’s keys come from a hybrid key exchange, X25519 together with ML-KEM, when both sides offer it. See Networking.
- The client dials one key and accepts no other. There is no trust on first use and no prompt to accept a new key.
- A relay forwards packets that are encrypted end to end. It cannot read or change them. See Connections.
- DNS, DHT and mDNS records only say where to knock. A wrong record leads to a failed connection, never to another daemon.
What is left:
- A relay, and anyone who watches the network, sees that two keys talk, when, and roughly how much. The public lookup records tie a daemon’s key to its relay. irsync does not hide who talks to whom.
- Anyone on the path can block or slow the connection.
- A recording of a connection could be decrypted later by someone with a
large quantum computer, when one side does not offer the hybrid key
exchange. No such machine exists today. irsync offers the hybrid
(
X25519MLKEM768), so two irsyncs use it, and a recording of their connection stays safe as long as X25519 or ML-KEM holds. A peer that does not offer it, such as an irsync built without it, gets X25519 alone, without a warning:-vvshows which one a connection got. Setpq_key_exchange = "require"to refuse such a connection instead; see Post-quantum key exchange. - The keys are Ed25519, which such a machine could forge too. That would let it pretend to be a daemon or a client from then on. It does not open up connections recorded before.
A key without a grant
What they could try: connect and see what the daemon reveals, or keep it busy.
What stops them:
- The daemon closes the connection at once, with no message, when no grant names the key. It reads its grants afresh for every connection.
- There is no open access:
alland*are refused as a grantee.
What is left: the daemon still pays for the handshake of every attempt. irsync has no rate limit of its own for strangers; use a firewall if that matters.
A client with a grant
What they could try: reach files outside the export, write to an export they may only read, learn where other exports are, take over another client’s session, or exhaust the daemon.
What stops them:
- A path is resolved and matched against the exports the key may use before
anything is said about it.
..and NUL are refused. A path outside those exports getsno access, the same answer as for a path that does not exist, so a key cannot map the daemon by probing. - Below the export’s directory, every existing component of the session’s root must be a real directory, not a symlink.
- A read-only grant, or an export marked
read_only, refuses every push. - Every path in a listing must be relative, with no
.., no., no empty part and no NUL. A listing must be in order, with no path twice. - Symlinks are stored as they are sent and are not followed when irsync walks a tree. A file listed below a symlink is refused.
- A file is read, written, renamed and deleted through its directory, and
that directory is opened step by step from the
export’s own directory with no symlink followed. A directory that was
swapped for a symlink after it was listed, for example by a second
session of the same client, makes the operation fail. It does not lead out
of the export. The same holds for a
--partial-dirthat is a symlink. - The walk that lists a tree checks every entry through its directory in the same way. A session root that has become a symlink is not walked.
- Deleting is done relative to a directory that was opened without following symlinks, never by descending into a link.
- A session can be resumed only by the key that started it.
- A key may leave only
max_dormant_sessions_per_keyinterrupted sessions stored in an export, 25 by default. The oldest is dropped when there are more. - Messages are limited to 16 MiB, the queues between the two sides have
fixed sizes, and an idle connection is dropped after
idle_timeout. - The filter rules a client sends are limited in number and size before the daemon compiles them, and so is a path the other side names for a file.
What is left:
- A read-write grant is real power inside the export. The client can replace or delete everything in it, fill the disk, and leave symlinks that point anywhere. irsync does not follow those links, but another program that reads the export might.
- Metadata is applied as sent, as with
rsync -a: permission bits including setuid, and, when the daemon runs as root, owners and device files. Do not run the daemon as root for keys you do not trust that far. - A granted client can use the daemon’s resources: CPU for hashing, disk reads, memory, and the sessions it has open at once. The limits above bound single messages, queues and stored sessions, not a client that works at being expensive. irsync does not treat a granted key as hostile to the daemon’s uptime.
admin = "rw"is the whole account too. Such a key can add an export for any directory and grant itself read-write access to it, so it can do whatall_paths = "rw"can. Give it with the same care.admin = "ro"only reads: the exports, clients and grants (names, paths and ids), and, throughconfig getandconfig list, every other setting in the file, such asstate_dir, the ids and addresses of the saved[servers.*]and the[defaults]settings. None of it is a secret.- Who can reach the admin service. Only a named client with
adminset. A key without it gets the plain answernot allowed, which says nothing about the server. A change is checked on the server, against the config as it is when the change lands, and applied all or nothing. A client cannot remove or lower its ownadminright through it, so a slip does not lock it out. At most 100 changes go in one call, and a session idle for 10 minutes is closed. - The audit log. The server logs every applied change at
infowith the client’s name, and every refused attempt atwarnwith the name, or the first digits of the key when it has none. Reads are not logged. The log holds no secrets, but it is the record of who changed what. all_paths = "rw"is the whole account. Such a key can reach any path the daemon’s account can. Give it only to machines you would give ssh access to.all_paths = "ro"is smaller, but it still reads the whole account:~/.ssh, irsync’s own config and, if the daemon’s key file is readable, the daemon’s identity key. Give it with the same care. See Rights on a client.
The daemon you connect to
A daemon you run yourself is as trustworthy as its machine. This section is about a daemon you do not control, or one that was broken into.
What it could try: on a pull, send other files than you asked for, write outside your destination, or read your local files. On a push, keep or change what you send.
What stops it:
- The same listing checks as above apply on the client: relative paths only, nothing below a symlink, nothing outside the destination directory.
- The client deletes only with a delete flag from its own command line, and only inside the destination. A listing that did not arrive whole stops the delete pass.
- Every chunk and every whole file is checked against its BLAKE3 hash before it is placed.
- When a file you already have changes, the sender may ask for parts of your old copy to be reused. The client reuses only whole blocks it described to the sender itself, so a sender cannot probe your old file for its content.
What is left:
- On a pull, the daemon decides what is in the listing. It can send files you did not expect, inside the destination. With a delete flag, a daemon that lists less makes you delete more, inside the destination. That is what the flag means. Pull from a daemon you do not trust into a directory of its own, never into your home directory, and look before you use what arrived.
- A daemon learns what you push, and can keep, change or drop it. irsync does not encrypt files at rest, and it cannot prove that a daemon still has your data. fileset can check a copy later against a manifest you keep yourself.
- Hashes show what the source sent, not what it should have sent. They catch damage on the way, not a source that lies.
- On a pull, the daemon can learn whether your destination already holds
some content. The daemon sends the hashes of each file’s chunks, and
the client asks only for the chunks it finds in no file of the
destination tree. That is what makes a renamed or copied file cost
nothing. It also means that a daemon which guesses the whole content of a
chunk can see whether the guess was right, also for files it never sent
you. A chunk is a whole small file, or 64 KiB to 1 MiB of a larger one.
The daemon learns nothing about content it cannot guess. Pulling into a directory of its own leaves nothing there to ask
about.
--no-rename-detectionmakes the client look only at the old version of the same file, at the price of fetching moved and copied files again. On a push there is nothing to learn this way: a key that may write to an export may read all of it anyway.
Whoever made the tree you sync
File names, symlinks and permissions travel with a tree. So does a
.fileset.sqlite, .fileset.fjall or .fileset.redb manifest inside it.
What they could try: names that confuse the terminal or a log, symlinks that point out of the tree, setuid files, or a manifest that says the copy is fine.
What stops them:
- Paths are shown escaped: control characters, bytes that are not UTF-8,
and the invisible characters that reverse the direction of text are
printed as
\ooo. - A log event stays on one line. Text from the other side cannot end a line and start one that looks like irsync wrote it.
- irsync never follows a symlink it copies.
- A manifest is compared with the files as they are now. It cannot make
filesetskip a file that is on disk. filesetrefuses a manifest in the tree that is a symlink, or that has symlinks inside. It opens a SQLite manifest with SQLite’s settings for files that are not trusted, and refuses one with views, triggers or virtual tables. In a redb manifest every entry carries a checksum of its path and content, and the manifest carries one of all its entries together, so an entry that is altered or gone is an error. The whole file is verified beforeupdatewrites to it, and a failure inside the database engine is reported as a damaged manifest. These checksums catch damage, not someone who rewrites the manifest and its checksums to match.
What is left:
- A manifest is only as good as where it came from.
fileset checkproves that a tree matches its manifest, not that the manifest is the original. Someone who can change the files can change the manifest too. Keep a copy you trust somewhere else, or compare root hashes over another channel. See How fileset works. - A manifest is a database file from someone else. The checks above
narrow what a crafted one can do; they do not make the database engines
safe against every crafted file. A
.fileset.fjallmanifest is repaired when it is opened, even bycheck, socheckcan write into it. redb does not check a file it only reads, and says that it may stop on one that was altered;filesetturns that into an error, but nothing fuzzes redb’s reading of a crafted file here. - Symlinks and setuid files arrive as they were. What other programs do with them is up to you.
Other users of the same machine
What they could try: read your key or state, or swap a directory for a symlink while a sync runs in a tree they can write.
What stops them:
- A new private key is created readable by its owner only, and an existing key is never overwritten.
- irsync stops when the config file, a private key or a passphrase file can
be read or written by other users, or belongs to another user. The config
file is checked before anything else happens. Setting
unsafe_config_allowed = truein the config file turns these checks off. - A file being received is readable by its owner only until it is placed.
- The index of file names and hashes sits in a directory only its owner can enter. A new config file and the daemon’s log are for the owner only.
What is left:
- Whoever can read a private key file is that identity. An encrypted key
(
irsync id generate --passphrase-file) helps against a copied file. - irsync does not defend a sync against another user who can write in the source or destination tree while it runs. Do not sync as root into, or out of, a tree that other users can change.
- irsync’s state directory holds the names and hashes of the files it synced. Protect it as you protect the files.
Pairing over ssh, and installing
irsync pairtrusts ssh: the server you log in to is the one irsync installs on and grants access to. Onlypairuses ssh; a sync never does. It gives this clientall_paths = "rw"andadmin = "rw"on that server.- Releases are signed. Verify a download shows how to check one, and Supply chain security how they are built.
What irsync does not defend against
In one place:
- A machine that is already broken into, on either side, or a stolen key file.
- A daemon you chose to trust that turns out to be hostile, beyond keeping it inside your destination directory. It can also check guesses about what that directory already holds.
- Traffic analysis: who talks to whom, when, and how much.
- A future quantum computer: it could forge a key, and decrypt a recorded connection in which one side did not offer the hybrid key exchange.
- A client with a grant, or a stranger, who sets out to use up the daemon’s CPU, memory, disk or network.
- Other users of the same machine who can write in the tree being synced.
- Files at rest. irsync encrypts the connection, not the disk.
- What other programs do with the symlinks, setuid files and device files a sync was asked to copy.
Where the review stands
The code was checked against this page in November 2026. The work is tracked in issue 126.
The review looked at the limits on what the other side may send, file
permissions, logs and terminal output, fileset manifests, the reuse of old
file content, how files are reached by name, and how the daemon resolves a
client’s path. What it found there is fixed, and the checks above describe
the code as it is now.
No gap found by the review is still open. What irsync leaves to you is listed under “What is left” in each section above, and in one place under What irsync does not defend against.
To report a security problem, see the security policy. Please do not open a public issue for one.
Connections
irsync connects a client and a daemon with iroh, over QUIC. A daemon is
addressed by its EndpointId, the public half of its key, not by a host name
or an IP address. This page explains how a client gets from that id to a
working connection, and what keeps the connection going. The steps to change
each part are in
Connect directly or through a relay.
Networking explains the layers underneath (lookups, hole
punching, QUIC, TLS and streams) and the standards behind them.
Finding the daemon
A daemon publishes where it can be reached, in up to three places, each turned
on or off by a key of the same name in [daemon]:
dns: n0’s DNS service, through signed pkarr records.dht: the mainline DHT, with the same kind of record.mdns: the local network.
A client looks the EndpointId up in the same places. Each can be turned off
per server or in [defaults], with the same three keys, and --no-dht,
--no-dns and --no-mdns turn one off for one sync.
The DNS and DHT records carry only the daemon’s relay address, never its IP addresses: that is iroh’s default, so that publishing an id does not publish where the machine is. mDNS announces the daemon’s local addresses, and only on the local network.
Whatever a lookup returns, the connection is to the key and nothing else: the TLS handshake inside QUIC proves both keys (see Networking). A lookup that returns a wrong address leads to a failed connection, not to a wrong peer.
Relays
A connection starts through a relay, a server both sides can reach, and moves to a direct path when hole punching succeeds. The relay forwards QUIC packets that are encrypted end to end between the client and the daemon; it cannot read or change them. n0 runs public relays, which are the default.
Relays are the fallback. Every packet takes the detour through the relay server and shares it with other users, so a relayed transfer is slower than a direct one. When one end sits behind a symmetric NAT, as many mobile and carrier-grade NATs are, and the other behind a symmetric or port-restricted NAT, hole punching fails and the connection stays on the relay. For them a self-hosted relay near the daemon is the better choice than the shared public ones.
Relays can be refused, on either side. A client with relays off still looks
the daemon up, but since the DNS and DHT records carry only a relay address,
it finds a daemon through mDNS on the local network or through an address it
is given. A daemon with relays off has nothing to publish in DNS or the
DHT; it warns at start when dht is on.
Direct addresses
Given an address, through --address or a host’s address key, the client
dials it and nothing else: no relay, no DNS, no DHT, no mDNS and no port
mapper. This is how two irsync processes talk on one machine, on a LAN, or
without internet access. The EndpointId is still required and still checked,
so an address only says where to knock, not whom to trust. Over the
connection, both sides still tell each other their local addresses, and iroh
may open more paths to them. A client given an address binds to the one
local address it dials from, so it offers no other; a daemon whose listen
names a specific address offers only that one. Together they keep the
connection on the dialled path (see
Keep to one path).
On the daemon’s side, listen pins the sockets it binds, at most one IPv4 and
one IPv6, and portmap asks the router for a port mapping with UPnP, PCP or
NAT-PMP. Pinning the sockets does not stop the publishing or the relay; an
isolated daemon turns those off one by one.
Keeping a connection alive
Two timers watch a connection, at different scales:
- QUIC’s own idle timeout, 60 seconds. Both sides send a keep-alive every 5 seconds, so this fires only when the path is gone: a laptop that sleeps, a network that drops.
- The daemon’s
idle_timeout, 30 minutes by default. The daemon drops an authenticated connection on which nothing has happened for that long. Something happening means any control message or file data on the wire, and also local progress on either side: chunks written or copied, hashing, finalizing a file (thefsyncand the whole-file check of a large.part), and each deletion. Hashing counts as progress every 64 MiB read, so a large file being hashed keeps the connection alive. A side with local progress sends a heartbeat every half second, so that the other side sees it.
When a connection drops, the client redials for up to reconnect (one day by
default) and resumes the session. A file that was being finalized when the
connection dropped does not fail: the resumed session waits up to 60 seconds
for the earlier connection’s finalize to release the .part file before it
reports the file busy.
idle_timeout = "0" disables the daemon’s limit; see
Configuration.
Congestion control
The side that sends picks QUIC’s congestion controller: the client for a push,
the daemon for a pull. The setting is congestion, in [defaults], in a host’s
table or in [daemon], and takes bbr, the default, or cubic.
- BBR keeps the queue at the bottleneck short and copes with random loss, as on mobile links.
- Cubic keeps the link busier when the return path delays the acknowledgements. That is typically an upload on a home line whose download is busy with other traffic: the queued download holds up the upload’s acknowledgements, and BBR then keeps too little data in flight to bridge the delay. Cubic fills the line’s queue instead, which adds latency for everything else on the line while it sends.
Measured in the netstress dsl-video profile, a 1 Mbit/s uplink beside a busy
downlink, Cubic was 1.6 to 1.8 times faster than BBR. In the lossy
4g-vehicle profile BBR was 23 to 50% faster, and Cubic’s full queue cost
other traffic on the line about 0.5 s of latency. Neither wins everywhere, so
BBR stays the default. The runs are in
NETSTRESS_DECISIONS.md.
Networking
irsync sends its messages over iroh, a library that gives two programs an
encrypted QUIC connection to each other, wherever they are. This page goes
through the layers from the bottom up. For each one it says what iroh does,
which standard it rests on, and where irsync’s code touches it.
The other pages go into detail. Connections covers the choices irsync makes on top of iroh and the settings that change them: lookups, relays, direct addresses, timers, congestion control. Protocol is the exact reference for irsync’s own messages. iroh’s own documentation is at iroh.computer and its API at docs.rs/iroh.
The stack
irsync messages Hello, Control, DataChunk, ... proto/irsync/v1/
frames varint length + one protobuf net/frame.rs
------------------------------------------------------------------------
QUIC streams control, listing, data session/, data_stream.rs
QUIC connection RFC 9000, multipath extension iroh
TLS 1.3 in QUIC RFC 8446, RFC 9001, RFC 7250, ALPN iroh
paths direct UDP (hole punched) or relay iroh
finding the peer EndpointId -> addresses iroh lookups
identity Ed25519 key pair iroh, identity.rs
Read it from the bottom up. Above the line is irsync’s own protocol. Below it
is iroh, which irsync configures in crates/irsync/src/net/endpoint.rs;
irsync supplies the key and decides which streams to open.
Identity: an endpoint is a key
Every iroh endpoint has an Ed25519 key pair
(RFC 8032). Its EndpointId is the
32-byte public key. That id is the address: a client dials an id, not a host
name or an IP address, and iroh makes sure the far end holds the matching
private key.
In irsync, the client and the daemon each have their own key
(crates/irsync/src/identity.rs). Identity and trust
explains where the keys come from and how the daemon decides what a key may
reach (crates/irsync/src/authz.rs).
Finding the other side
An id says whom to reach, not where. iroh turns an id into addresses with address lookups, pluggable services that each publish and resolve records:
- DNS, through pkarr. pkarr records are small DNS records signed with the endpoint’s own key, so nobody else can forge them. n0, the company behind iroh, runs the DNS server that serves them.
- The mainline DHT. The same signed records, stored in BitTorrent’s distributed hash table (BEP 5), as signed mutable items (BEP 44). No single company runs it.
- mDNS, multicast DNS on the local network (RFC 6762).
irsync adds each lookup that is turned on in build in
crates/irsync/src/net/endpoint.rs. Which are on by default, and what each
one publishes, is in Connections. With
an address given by hand (--address), irsync turns every lookup off and
dials that address.
Paths: relays and hole punching
Most machines sit behind a NAT, a router that shares one public address among the machines behind it and drops unsolicited packets from outside. Two such machines cannot simply send each other packets. iroh deals with this in two ways.
Relays. A relay is a server both sides can reach. Each endpoint keeps a connection to its home relay, over HTTPS upgraded to a WebSocket (RFC 6455); the relay protocol is derived from Tailscale’s DERP. The relay forwards QUIC packets between the two endpoints. It cannot read them: they are encrypted end to end.
Hole punching. Both sides send packets to each other’s public address at about the same time, so that each NAT sees outgoing traffic and lets the answers in (RFC 5128 describes the technique). To learn its own public address, an endpoint asks the relay servers, using QUIC address discovery (draft-ietf-quic-address-discovery). The two sides exchange their candidate addresses inside the connection, with an extension based on draft-seemann-quic-nat-traversal.
A connection starts on the relay and moves to a direct path once hole
punching works. When it doesn’t, the connection stays on the relay. A sync
logs which it got at info level (connected directly or
connected through a relay);
Connect directly or through a relay shows
how to check and how to change it.
In irsync, the relay choice and the port mapper are set in
crates/irsync/src/net/endpoint.rs. The in-process network tests replace all
of this with a simulated link, plugged in as an iroh custom transport
(crates/irsync/src/net/netsim/).
QUIC
QUIC (RFC 9000) is a transport protocol over UDP. Like TCP, it delivers bytes reliably and in order, and it backs off when the network is congested. Unlike TCP, it carries many independent streams in one connection, encrypts everything, and can keep a connection alive while the network path under it changes.
iroh’s QUIC implementation is noq, a fork of the Rust library quinn. irsync
sets its transport parameters in transport_config in
crates/irsync/src/net/endpoint.rs: the idle timeout and keep-alive, the
flow-control windows, the stream limits, the congestion controller and how
often the peer acknowledges.
TLS 1.3 inside QUIC
QUIC has a handshake of its own (RFC 9000, section 7), and that handshake carries a TLS 1.3 handshake (RFC 8446) in its first packets. The keys TLS agrees on then encrypt every packet after that (RFC 9001). iroh uses the rustls TLS library.
Two TLS extensions matter here:
- Raw public keys (RFC 7250).
Instead of a certificate signed by an authority, each side presents its
bare Ed25519 public key and proves it holds the private key. The key is
the
EndpointId, so the handshake proves identity directly. Both sides present a key: the daemon learns the client’s id from the handshake (conn.remote_id()incrates/irsync/src/daemon.rs), before any irsync message. - ALPN, application-layer protocol negotiation
(RFC 7301). The client names the
protocol it wants to speak, and the server accepts it only if it speaks it
too. irsync’s is
irsync/1(ALPNincrates/irsync-proto/src/lib.rs). The daemon’s endpoint accepts nothing else. The version of irsync’s own protocol travels separately, inHello.
The key exchange. The two sides agree on the connection’s keys with
X25519MLKEM768, a hybrid of two methods: X25519, the classical one, and
ML-KEM, which is built to hold against a quantum computer
(FIPS 203). The keys are safe
as long as either of the two holds. irsync offers the hybrid first and the
classical groups after it (crypto_provider in
crates/irsync/src/net/endpoint.rs), so a peer that does not know the
hybrid, such as an irsync before this change, still connects, with X25519.
ML-KEM comes from aws-lc-rs, the crypto library rustls runs on here.
To refuse a connection that did not get the hybrid, set
pq_key_exchange = "require"; see
Post-quantum key exchange.
It is a check after the handshake, before the first irsync message: both
sides still offer the classical groups, because the relays and lookup
servers, which use the same list, do not know the hybrid yet. Nobody on the
path can take the hybrid out of the offer unnoticed, since TLS signs the
whole handshake.
The group a connection got is in the logs at info level (-vv):
handshake done key_exchange=X25519MLKEM768 on the client and
connection accepted with the same field on the daemon. The client’s
-vv summary names it too, after direct or relay.
With SSLKEYLOGFILE set, rustls writes the TLS secrets to a file so that
Wireshark can decrypt a packet capture; see
Trace and capture the protocol.
Streams and flow control
A QUIC stream is an ordered byte stream inside the connection. Either side can open one, and it is either bidirectional or unidirectional (one side writes, the other reads). Streams are independent: a lost packet holds up only the streams whose data it carried.
Each stream has an id. Its two lowest bits say who opened it and what kind it is (RFC 9000, section 2.1): 0, 4, 8, … are bidirectional streams opened by the client, 2, 6, 10, … unidirectional ones opened by the client, and 3, 7, 11, … unidirectional ones opened by the server. The trace below shows these ids.
Flow control keeps a fast sender from overrunning a slow reader. The reader
grants how many bytes it will take, per stream and for the whole connection,
and raises the limit as it reads. It also grants how many streams the other
side may have open at once. irsync’s numbers are in transport_config: 8 MiB
per stream, 64 MiB per connection, up to 256 unidirectional and 8
bidirectional streams.
Multipath
QUIC’s multipath extension (draft-ietf-quic-multipath) lets one connection use several network paths, each with its own packet numbers and congestion state. iroh turns it on and treats the relay and each direct address as paths of the same connection. Moving from the relay to a direct path is moving traffic to another path, not opening a new connection: streams carry on untouched, and irsync never notices.
irsync only watches which path is in use: the trace and the capture record a
PathChange whenever it changes (selected_path in
crates/irsync/src/net/tap/mod.rs).
irsync’s layer
On top of the streams, irsync sends protobuf messages, defined in
proto/irsync/v1/. Each message is a frame: its length as a protobuf
varint (a number written 7 bits per byte), then the message’s bytes. This is
protobuf’s standard length-delimited form. write_msg and read_msg in
crates/irsync/src/net/frame.rs write and read frames; a frame over 16 MiB is
refused before anything is allocated for it.
A session uses three kinds of stream, all opened by the side that dials, except data streams on a pull:
- the control stream, the client’s first bidirectional stream: the
handshake, then the plan, the chunk lists, the requests and the
acknowledgements (
crates/irsync/src/session/engine.rs); - the listing stream, the second bidirectional one: each half carries one
side’s listing (
crates/irsync/src/session/listing_stream.rs); - data streams, unidirectional, from the side that sends files to the side
that receives them, one per run of chunks of one file
(
crates/irsync/src/data_stream.rsopens them,crates/irsync/src/session/receiver/file_io.rsaccepts them). On a push the client opens them; on a pull the daemon does.
When a connection ends, the side that closes it gives a QUIC application close code: 0 done, 1 unauthorized, 2 rejected, 3 superseded, 4 idle. Protocol lists what each one means for the client.
One push, message by message
Here is a real push of two small files, a.txt (6 bytes) and b.txt (12
bytes), from a client to a daemon on the same machine, into an empty export
photos. The client ran with the protocol trace on:
RUST_LOG=info,irsync::wire=trace irsync -av --address 127.0.0.1:57528 ./src/ <daemon-id>:photos/
These are the client’s irsync::wire lines, trimmed to fit: the timestamp,
the log span and the fields that are the same on every line (side, conn,
session) are cut, STREAM_KIND_ and DIRECTION_ are dropped from the
values, the session id is shortened, and some file metadata is replaced by
…. Trace and capture the protocol
shows a full line.
The connection. iroh reports the path it chose, here a direct UDP path to the address given, and the client opens the control stream, QUIC stream 0.
PathChange { remote: "ip:127.0.0.1:57528" } dir="UNSPECIFIED" stream="UNSPECIFIED" quic_stream=0 file=-
StreamEvent { kind: OPENED } dir="UNSPECIFIED" stream="CONTROL" quic_stream=0 file=-
The handshake. Hello names the protocol version and asks for a
push: the remote path, the chunking parameters and the rsync flags. The
daemon has already checked the client’s key during the TLS handshake. It
answers with a HelloReply holding a HelloAck and a new session id.
Hello { protocol_version: 8, build: BuildInfo { … }, push: SyncRequest { path: "photos", contents_only: true, chunk_min: 65536, chunk_avg: 262144, chunk_max: 1048576, preserve: Preserve { links: true, perms: true, times: true, … }, recursive: true } } dir="SENT" stream="CONTROL" quic_stream=0 file=-
HelloReply { ack: HelloAck { session_id: 0x88f83bf9…, build: BuildInfo { … } } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=-
The listings. The client opens the listing stream, QUIC stream 4 (the
next client bidirectional stream), and names the session on it. Then both
sides list at once, each on its own half: the client its source directory and
two files, the daemon its export, which holds only the directory itself. Each
half ends with a ListingEnd and the end of the half.
StreamEvent { kind: OPENED } dir="UNSPECIFIED" stream="LISTING" quic_stream=4 file=-
ListingStreamHeader { session_id: 0x88f83bf9… } dir="SENT" stream="LISTING" quic_stream=4 file=-
ListingFrame { entry: FileEntry { kind: DIRECTORY, size: 80, … } } dir="SENT" stream="LISTING" quic_stream=4 file=-
ListingFrame { entry: FileEntry { path: "a.txt", size: 6, … } } dir="SENT" stream="LISTING" quic_stream=4 file=-
ListingFrame { entry: FileEntry { path: "b.txt", size: 12, … } } dir="SENT" stream="LISTING" quic_stream=4 file=-
ListingFrame { end: ListingEnd { count: 3 } } dir="SENT" stream="LISTING" quic_stream=4 file=-
StreamEvent { kind: FINISHED } dir="SENT" stream="LISTING" quic_stream=4 file=-
ListingFrame { entry: FileEntry { kind: DIRECTORY, size: 40, … } } dir="RECEIVED" stream="LISTING" quic_stream=4 file=-
ListingFrame { end: ListingEnd { count: 1 } } dir="RECEIVED" stream="LISTING" quic_stream=4 file=-
StreamEvent { kind: FINISHED } dir="RECEIVED" stream="LISTING" quic_stream=4 file=-
Heartbeats, which say “this side is busy”, go back and forth on the control stream throughout; they are left out here.
The plan. The daemon, the receiver on a push, compares the listings and
asks for both files. It gives each a file id, which later messages use
instead of the path. No action is printed: fields at their default value
are left out, and the default is WHOLE, send the whole file.
Control { plan: PlanItem { file_id: 1, path: "a.txt" } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=1
Control { plan: PlanItem { file_id: 2, path: "b.txt" } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=2
Chunk lists and requests. The client hashes each file and sends its chunk list: here one chunk per file, whose hash equals the whole file’s. The daemon has none of the chunks and asks for chunk 0 of each.
Control { chunk_list_start: ChunkListStart { file_id: 1, whole_hash: Hash { bytes: 8e4c7c1b99dbfd50e7a95185fead5ee1448fa904a2fdd778eaf5f2dbfd629a99 }, total: 1, stat: SourceStat { size: 6, … }, chunks: [ChunkRecord { len: 6, hash: Hash { bytes: 8e4c7c1b… } }], … } } dir="SENT" stream="CONTROL" quic_stream=0 file=1
Control { chunk_list_start: ChunkListStart { file_id: 2, whole_hash: Hash { bytes: 07c6fb3c62e3e04169dbe5acf2dba4a25213680c5f60e0fc557d94a2085db649 }, total: 1, stat: SourceStat { size: 12, … }, chunks: [ChunkRecord { len: 12, hash: Hash { bytes: 07c6fb3c… } }], … } } dir="SENT" stream="CONTROL" quic_stream=0 file=2
Control { need: NeedChunks { file_id: 2, chunk_idx: [0] } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=2
Control { need: NeedChunks { file_id: 1, chunk_idx: [0] } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=1
The data. The client opens one unidirectional stream per file, QUIC
streams 2 and 6, and sends each chunk on it after a DataStreamHeader. The
two streams run side by side. The trace never prints file content: a chunk
shows as its length and the start of its BLAKE3 hash, which matches the chunk
list above.
StreamEvent { kind: OPENED } dir="UNSPECIFIED" stream="DATA" quic_stream=2 file=-
DataStreamHeader { session_id: 0x88f83bf9…, file_id: 2, length: 12 } dir="SENT" stream="DATA" quic_stream=2 file=2
StreamEvent { kind: OPENED } dir="UNSPECIFIED" stream="DATA" quic_stream=6 file=-
DataChunk { data: <12 bytes, blake3 07c6fb3c62e3e041> } dir="SENT" stream="DATA" quic_stream=2 file=2
DataStreamHeader { session_id: 0x88f83bf9…, file_id: 1, length: 6 } dir="SENT" stream="DATA" quic_stream=6 file=1
StreamEvent { kind: FINISHED } dir="SENT" stream="DATA" quic_stream=2 file=2
DataChunk { data: <6 bytes, blake3 8e4c7c1b99dbfd50> } dir="SENT" stream="DATA" quic_stream=6 file=1
StreamEvent { kind: FINISHED } dir="SENT" stream="DATA" quic_stream=6 file=1
Placing the files. The daemon has verified each file against its chunk
list and asks whether it may place it. The client checks that the source has
not changed since it was hashed and says yes (changed: false, the default,
so not printed). The daemon then places the file and acknowledges it, and
gives back the room the chunk list took.
Control { may_place: MayPlace { file_id: 1, gen: 1 } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=1
Control { may_place: MayPlace { file_id: 2, gen: 1 } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=2
Control { place_verdict: PlaceVerdict { file_id: 1, gen: 1 } } dir="SENT" stream="CONTROL" quic_stream=0 file=1
Control { place_verdict: PlaceVerdict { file_id: 2, gen: 1 } } dir="SENT" stream="CONTROL" quic_stream=0 file=2
Control { ack: FileAck { file_id: 1, status: DONE } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=1
Control { list_room: ListRoom { records: 1 } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=-
Control { ack: FileAck { file_id: 2, status: DONE } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=2
Control { list_room: ListRoom { records: 1 } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=-
The end. The daemon sends the session’s totals, and both halves of the
control stream finish. The connection then closes with code 0, done.
Control { done: SessionDone { files_placed: 2, bytes_received: 18, created: 2, placed_size: 18 } } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=-
StreamEvent { kind: FINISHED } dir="RECEIVED" stream="CONTROL" quic_stream=0 file=-
StreamEvent { kind: FINISHED } dir="SENT" stream="CONTROL" quic_stream=0 file=-
The daemon’s trace of the same push shows the same messages with sent and
received swapped. What each message means in full is in
Protocol; why the receiver
plans and the sender only answers is in
The transfer algorithm.
The transfer algorithm
How irsync moves a changed file, set against how rsync does it. rsync facts
refer to protocol 30 and later (rsync 3.x). The receiver’s side of one changed
file, step by step, is in
Receiving a changed file; the messages are in
Protocol.
The two algorithms
rsync
The receiver keeps the old file as a basis. Its generator process cuts the basis into fixed blocks (block size about the square root of the file size, rounded to a multiple of 8, clamped to 700 bytes .. 128 KiB) and sends, per block, a 4-byte rolling checksum plus a truncated MD5 (2 to 16 bytes, chosen per file). The sender slides a one-byte window over the new file; on a weak hit it checks the strong checksum, and emits a token stream of literal bytes and block references. The receiver rebuilds the file into a temporary, computing the whole-file MD5 as it writes, then renames it into place. On a whole-file mismatch the file is redone once with full-length checksums. Everything flows in order over one TCP or SSH stream, through three pipelined processes (generator, sender, receiver).
irsync
The sender cuts the new file into content-defined chunks (FastCDC 2020, 64 KiB minimum, 256 KiB average, 1 MiB maximum) and hashes each chunk and the whole file with BLAKE3. Both sides keep these hashes in a persistent index, keyed on size, mtime, ctime and inode, so an unchanged file is never read twice.
- The receiver’s planner compares the two listings and requests a file with a
PlanItem:WHOLEwhen nothing is at the path,DELTAwhen it holds an old version. For aDELTAit starts hashing the old version at that moment. - The sender digests the new file, from its index when the file is unchanged there and by reading it otherwise, and sends the chunk list.
- If the old file’s hash equals the new one, the receiver applies the sender’s metadata to the file in place and is done: no write.
- Otherwise the receiver opens
.irsync.<name>.part, as a reflink clone of the old file where the filesystem allows, and keeps the chunks the clone or an earlier interrupted attempt already holds. It looks the missing chunks up in its index: those any indexed file holds are copied locally, the rest are requested from the sender withNeedChunksat once. - For a
DELTA, the receiver first offers the sender a basis for each requested chunk: block signatures over the old file around the chunk’s place. The sender answers such a chunk with copies and literals instead of its bytes when that is smaller. This is rsync’s algorithm, run inside one chunk. - The sender reads each requested chunk, hashes it again as it reads, and streams the chunks over parallel QUIC streams. The receiver verifies every chunk against its hash before writing it, whether it came raw, rebuilt from operations or from a local file.
- The receiver folds the whole-file BLAKE3 from the verified chunks, without
reading the file back, applies the metadata, renames the
.partinto place, and acknowledgesDONE.
Local copies run while the network transfer runs, and the sender’s hash runs while the receiver hashes its old file. A whole file and a moved file take the same path: for a moved or copied file, every chunk is found locally.
The delta inside a chunk
A content-defined chunk resynchronises within about one chunk after an edit, so whole-chunk reuse alone would cost one or two chunks, 64 KiB to 1 MiB, per edit. irsync narrows that to blocks:
- For a missing chunk at offset
oof lengthn, the basis is the old file’s bytes fromo - ntoo + 2n, clamped to the old file. A chunk that starts at or past the old file’s end (appended data) gets none. A file missing more than half of its chunks gets none, unless it has at most two chunks: that is a rewrite. The regions stop once they add up to the old file’s size or three maximum chunk lengths, whichever is more. - The block length is the square root of the region, clamped to 512 B .. 4 KiB. Each block is signed with a 32-bit rolling sum and the first 8 bytes of its BLAKE3 hash, 12 bytes per block.
- The sender slides a window over the chunk’s bytes, checks every position against a 64 Ki-bit filter, then the signatures, then the strong hash, and emits copies of old-file ranges and literals. If the result is not at least a quarter smaller than the chunk, the chunk goes raw.
- The receiver takes copies only from whole blocks it signed for that chunk. A sender that could ask for any byte of the old file could find out what the file holds, one guess at a time.
- The receiver rebuilds the chunk and verifies its 32-byte hash. A chunk that does not verify (the old file changed in place, a hostile operation list, a collision of the 8-byte hash) is requested again, without a basis.
The integration tests in crates/irsync/tests/sub_chunk_delta.rs measure the
bytes on the data path, which leave out the chunk list and the signatures:
| Scenario | Whole chunks only | With the delta |
|---|---|---|
| 4 MiB file, one byte changed | one chunk, ~256 KiB | 2,100 bytes |
| 16 MiB file, eight scattered 4 KiB writes | eight chunks, ~2 MiB | 51,475 bytes |
| 100 KiB file, six bytes changed | the whole file | 550 bytes |
| 4 MiB file rewritten | 4 MiB | 4 MiB, no bases offered |
| 2 MiB appended to 4 MiB | ~2 MiB | ~2 MiB, at most one basis |
The signatures cost the other way about 12 bytes per block: for a 256 KiB chunk with a 768 KiB region at 886-byte blocks, 887 blocks, about 10 KiB, or 4% of the chunk.
Files in flight and streams
Two numbers bound how much a session has going at once.
- Files in flight: at most 4,096 per session, counted from the
PlanItemto the acknowledgement (MAX_INFLIGHTincrates/irsync/src/session/receiver/planner.rs). A file in flight may hold two descriptors, its.partand its old version, so the window shrinks to (soft open-file limit − 256) / 2 when that is smaller. At startupirsyncraises its soft limit to the hard limit (on macOS to at most 10,240), so the window is the full 4,096 wherever the hard limit is at least 8,448. A fresh file’s.partis opened by its first write, so files waiting for the sender’s data hold no descriptor. - Data streams: the sender keeps at most
--parallelQUIC streams open at once, across all files of the session, 128 by default (DEFAULT_PARALLELincrates/irsync/src/data_stream.rs). A daemon that sends always uses 128. A run of contiguous chunks longer than 64 MiB is split, so one large file spreads over several streams.
The first hides the per-file round trips; the second fills the link.
Compared with rsync
| Dimension | rsync | irsync |
|---|---|---|
| Delta unit | basis block (700 B .. 128 KiB, ~sqrt(size)), matched at any byte offset | content-defined chunk (64 KiB .. 1 MiB, 256 KiB average), matched whole anywhere the index knows; inside a missing chunk of a DELTA file, blocks (512 B .. 4 KiB) matched at any byte offset of the old file’s neighbourhood |
| Smallest file that gets a delta | any (blocks go down to 700 B) | any whose old version on the receiver is at least 1 KiB and whose new version is at least 512 B (blocks go down to 512 B) |
| What a 1-byte edit in a 1 GiB file sends | ~32 KiB literal + tokens | ~1 KiB literal + a few operations, with ~10 KiB of block signatures the other way |
| Signature direction | receiver to sender (basis blocks) | sender to receiver (new file’s chunks); receiver to sender (block signatures, per missing chunk of a DELTA) |
| Signature size, 1 GiB file | ~224 KiB (32,768 blocks of 32 KiB x 7 B: 4 B rolling + 3 B strong checksum, the length rsync’s sum_sizes_sqroot picks for this file size and block size) | ~200 KiB (4,096 chunks x 49 B), plus ~10 KiB per missing chunk offered a basis |
| Signature for a new file | none | full chunk list, ~0.02% of the data |
| Reuse scope | the basis at the same path (--fuzzy, --link-dest, --compare-dest widen it) | every chunk of every file the receiver’s index knows; before a whole file is fetched, up to four destination files of its size are hashed into the index |
| Rename detection | none (name similarity only, --fuzzy) | by content: a renamed or copied file’s chunks are found in the index and copied locally |
| Digest caching across runs | none; -c re-reads everything | persistent SQLite index keyed on size, mtime, ctime, inode; -c trusts none of it and re-reads both sides |
| Content unchanged, mtime changed | the file is rebuilt and rewritten | one read on each side whose index row is stale; metadata applied in place, no write |
| Round trips before first data byte | ~0 (pipelined) | 1.5 (plan, chunk list, request) |
| Serial disk passes before first data byte, one big changed file | 1 (basis checksums) | 1 (the sender’s hash and the receiver’s old-file hash run concurrently; local copies overlap the transfer) |
| Extra receiver pass after last byte | none (MD5 computed while writing) | none (BLAKE3 folded from the verified chunks) |
| Streams | one, in order | up to --parallel QUIC streams (128 by default), runs split at 64 MiB |
| Files in flight | pipelined, bounded by the window | up to 4,096 per session, fewer when the open-file limit is low |
| Resume | --partial keeps bytes; the next run re-checksums them | chunk-granular, verified ranges persisted, an unfinished chunk continued; plan persisted |
| In place, append | --inplace, --append, --append-verify | the same three; by default a .part that is a reflink clone of the old file where the filesystem allows, so only changed chunks are written and the file is still renamed into place |
| Per-block integrity | 4-byte rolling + 2..16-byte MD5 | 32-byte BLAKE3, checked when the sender reads and before the receiver writes |
| Whole-file integrity | MD5 (xxh3 negotiable in 3.2+), one redo | BLAKE3, folded from the verified chunks; a mismatch re-offers the file once |
| Change during transfer | noticed at the final whole-file check; whole file redone | a change while the file is hashed, or after it, is noticed (the sender stats the file after hashing, the receiver asks the sender before placing, and each chunk is checked as it leaves), and the file is re-offered once, then given up with exit 23; --paranoid also sends from a reflink clone or hashes again, and re-checks every listed file at the end (Files that change during a sync) |
| Sparse files | -S finds zero runs at write granularity | all-zero chunks are left as holes |
| Compression | -z | none |
| Largest file | no protocol limit | 2^24 chunks per list, about 4 TiB of typical data |
| Transport | TCP or SSH | iroh QUIC, NAT traversal, pinned Ed25519 identities |
Where irsync is ahead
- Touched files. A file whose mtime changed and whose content did not (a
touch, an editor that saved the same bytes, a restore) costs one read on each side whose index row is stale and four small messages; the destination keeps its inode and takes the new metadata. rsync rebuilds and rewrites it. - Moved, renamed and duplicated data. Any chunk anywhere in the indexed
destination is reused, so a renamed 10 GiB file transfers nothing; rsync
sends it again. A destination that rsync or a restore filled is hashed into
the index on demand, or ahead of time by
irsync index. - Small edits in large files. The delta block is chosen per chunk, not per file, so a one-byte edit in a 1 GiB file costs about 1 KiB of literal against rsync’s 32 KiB, and a hundred scattered 4 KiB writes about 0.6 MiB of literals and 1 MiB of signatures against rsync’s 3.2 MiB of literals and 224 KiB of signatures.
- Atomic and cheap updates at once. Where the filesystem clones files, a
changed file costs only its changed chunks in space and writes and still
lands by rename. rsync gets the first only with
--inplace, which gives up the second. - No read-back. The receiver reads a received file at most once, to verify chunks it adopted or copied locally, and writes it once; the whole-file hash is folded from what it verified.
- Bad and fat links. Many parallel streams, large files split across
them, a scan that runs alongside the transfer, and chunk-granular resume
across disconnects, process deaths and reboots (see
Sessions and resume). rsync’s single in-order
stream is limited by one congestion window, and
--partialkeeps bytes that the next run checksums again. - Integrity. Every chunk is checked with a 32-byte BLAKE3 hash when the
sender reads it and again before the receiver writes it, and the whole file
against its BLAKE3 hash, against rsync’s 2- to 16-byte truncated MD5 per
block. A chunk that changed after the file was hashed is caught when the
sender reads it, before stale bytes leave. A change while it is being
hashed, or after it in chunks the receiver takes from its own copy, is
caught by a stat of the source after hashing and before placing. Writers
that leave the times alone, such as memory-mapped databases, are not
caught by these.
--paranoidmay help, but is tested on ZFS 2.4 clones only. See Files that change during a sync. - Sender CPU. A changed or new file costs the sender BLAKE3 hashing only: one pass for its chunk list, and each requested chunk hashed again as it is read for sending. The rolling match runs only over chunks the receiver offered a basis for, not over every byte of every changed file.
- Reachability and identity. NAT traversal and pinned keys without SSH or port forwarding (see Identity and trust). This is irsync’s reason to exist, not a property of the algorithm.
Where rsync is ahead
- Compression. rsync’s
-zreduces the bytes on the wire for compressible data; irsync has no compression (see Known limitations). - Zero round trips before the first data byte. rsync’s generator runs
ahead and the sender’s token stream follows without waiting. irsync spends
four control messages per file and 1.5 round trips before its first data
byte:
PlanItem, chunk list,NeedChunks, then data, thenFileAck. Up to 4,096 files in flight hide this, but do not remove it: a file holds its slot from itsPlanItemuntil itsDONE, so one slow file holds a slot for its whole life. BeforeNeedChunksgoes out, the receiver also runs one SQLite lookup per missing chunk. - The first push reads the source twice. Each new file is read once for its chunk list and once to send it. rsync reads a new file once. The page cache hides the second read for files that fit in memory, and four hashing workers overlap it across files.
- Delta reach. A missing chunk is matched only against the old file’s neighbourhood of its own offset. Content that moved by more than about a chunk, and is not a whole chunk, is sent as literal; rsync finds it anywhere in the basis. Whole chunks are found anywhere through the index.
- Sparse files. irsync leaves only whole zero chunks as holes, so a run of
zeros shorter than a chunk is written. rsync
-Sfinds zero runs at write granularity. - Fixed chunk parameters. The chunk sizes are protocol constants. Changing them needs a new protocol version and invalidates every index on every machine.
- Memory per file in flight. The receiver holds two copies of a file’s chunk list while it is in flight, about 48 bytes per chunk each, which adds up when many large files are in flight at once.
- Opportunistic candidates. Before fetching a whole file, the receiver
hashes only destination files of exactly its size, at most four, of at
least 64 KiB, and only those its walk has already listed. Seeding the index with
irsync indexorindex_at_startcovers the rest. - Largest file. A chunk list holds at most 2^24 records, about 4 TiB of typical data; rsync has no such limit.
- Extended attributes and ACLs. rsync copies them with
-Xand-A; irsync copies neither (see Known limitations).
A limit both share: with --inplace reuse is forward-only, so an insertion
near the start of a file loses the reuse below it, in rsync and in irsync
alike. Without --inplace, irsync does not pay it.
Receiving a changed file
How the receiver fills one changed file once the sender’s chunk list is in
hand: how it overlaps the passes over the file with each other and with the
network, how it settles a file whose content turns out not to have changed,
and how a chunk it lacks is rebuilt from block matches against the old file.
Function names point at where each step lives, under
crates/irsync/src/. The comparison with rsync is in
The transfer algorithm; the messages are in
Protocol.
The problem
A DELTA file exists on both sides as a regular file and differs in size or
mtime. The sender digests the new content and sends its chunk list; the
receiver must produce a file whose every chunk verifies against that list,
then put it into place.
Four things have to happen for that: the sender hashes the new file, the receiver hashes the old one, chunks the receiver already holds are copied locally, and the rest cross the network. Done one after another, the first three are each a full pass over the file, and the transfer, the only part that needs the network, waits for all of them. The receiver runs them overlapped instead, and keeps these guarantees: every byte of the file is verified against the sender’s hash before it counts, local data is trusted no more than network data, and a stale local source degrades to a network fetch.
The timeline of one DELTA file
Plan time: the old file’s hash starts early
Planner (session/receiver/planner.rs) merge-joins the two listings and calls
plan::decide. When the decision is Delta, at the moment the PlanItem is
handed to the control stream, the planner spawns a task that runs
file_io::index_old_file on the destination path.
index_old_file takes an lstat (size, mtime, ctime, inode) and asks the
session’s hasher for the file’s digest. A fresh index row answers at once;
otherwise the file is read in full, cut with FastCDC, and every chunk’s BLAKE3
hash and offset is stored in the index with the whole-file hash. If the file
vanished, is not regular or cannot be read, the failure is logged at debug
level and nothing else follows from it: no local chunks are found, and
everything comes over the network.
The task’s handle travels with the file to the receiver. Meanwhile the sender
has received the PlanItem and begun its own digest of the new file, so the
two full reads run on two machines at the same time.
A WHOLE file has no old content, so no task is spawned. A moved or copied
file needs no step of its own: its chunks are in the index like any other
file’s and surface through the lookup below, which --no-rename-detection
turns off.
Chunk list arrival
The chunk list arrives as a ChunkListStart and ChunkListMore frames,
which Receiver::on_chunk_list_start and on_chunk_list_more reassemble
(session/parts.rs) into one digest. A malformed sequence fails the file. A connection lost in the middle
of a sequence drops the half-built list; the resumed session gets a fresh
sequence.
Receiver::on_chunk_list (session/receiver/mod.rs) bumps the file’s
generation, retires any earlier writer for the file, so that no stale task can
touch the .part afterwards, takes the hash task’s handle out of the file’s
state, and spawns open_writer. The handle is taken, not cloned: a second
chunk list for the same file, after a reconnect, finds none, and open_writer
calls index_old_file itself, which by then is a cache hit.
Open and partition
file_io::open_writer copies nothing. It:
-
Takes the old file’s hash (
DELTAonly): it awaits the handle, which yields the old file’s digest with the stat it was computed under. Without a handle it callsindex_old_file. -
Compares whole-file hashes. If the old file’s size and BLAKE3 hash equal the chunk list’s, the destination already holds the new content. The receiver opens it without following symlinks and checks with
fstatthat size, mtime, ctime, device and inode are those the hash was computed under (unchanged_file). If they are, it returnsOpened::Identicalwith that descriptor, and no.partis created; see Settle in place. If the file changed meanwhile, or the hashes differ, it goes on. -
Opens the
.part, locked (FileWriter::open_tracked). The writer adopts the progress recorded for an earlier.partof the same expected file and keeps a verified bit per chunk, and how many bytes it holds of each chunk an earlier connection left unfinished. When there is no.partyet and no old file to clone, the open is deferred: the writer holds no descriptor until its first write creates and locks the file. A file waiting for the sender’s data thus costs no open file. -
Partitions the missing chunks (
local_sources). On one of the index’s read connections,find_chunkslists the files that hold each missing chunk, with the inode and size each entry records: the first alone, since it nearly always is still there, then pages of 16. The first candidate that is still the file the index describes (same inode and size on disk) gives a path and an offset, and the chunk goes into the local set. Files that are gone or were replaced are passed over and queued for removal from the index, so a deleted tree’s leftovers cost onelstateach, once. A chunk with no such file goes into the remote set. If the lookup itself fails, the whole missing set goes remote, which is always correct.For a
WHOLEfile the partition is preceded bywarm_candidates: the receiver’s walk noted every regular file of at least 64 KiB without a fresh index row, by size (warm::Cold), and up to four of exactly this file’s size are hashed now, so a renamed or copied file the index did not know is found by the lookup. Each candidate is tried once per session. -
Picks bases (
DELTAwith an old file and a non-empty remote set).basis_specschooses which remote chunks to offer a basis for, and the old-file region of each: from one chunk length before the chunk’s offset to two after, clamped to the old file. A chunk starting at or past the old file’s end gets none; no chunk gets one when more than half the chunks are missing, unless the file has at most two; a region under 1 KiB is skipped; and the regions stop once they add up to the old file’s size or three maximum chunk lengths, whichever is more. If any basis is chosen, the old file is opened without following symlinks, and that descriptor is used for the signatures and later for the copies, so a rename of the destination meanwhile changes nothing.
The result carries the writer, the two sets, the digest, the basis choices and the old file’s descriptor. The sets are disjoint and together cover exactly the missing chunks; the chunks with a basis are a subset of the remote set.
Request first, then copy
Receiver::on_opened runs on the receiver’s event loop. When both sets are
empty, every chunk was adopted: the receiver sends an empty NeedChunks
(every chunk list needs an answer, and an empty one tells the sender to move
on) and finalizes. Otherwise it builds a route for the data streams:
| Field | Meaning |
|---|---|
gen | The file’s generation; stale streams and task results carry an older one and are ignored. |
slot | The one writer that both fillers share, behind a mutex. |
digest | The chunk table: offset, length and hash per chunk. |
pending | Units of delivery still running; see Completion. |
path | The file’s path, for events and logs. |
old | The old file’s descriptor while bases over it are out, for rebuilding chunks from operations. |
pending starts at the number of remote chunks, plus one if the local set is
not empty: one unit per remote chunk and one for the whole local copy task.
Then, in this order:
- the route goes into the routing table, so the earliest data stream finds it;
NeedChunksfor the remote chunks without a basis goes out;- if any basis was chosen,
offer_basesis spawned, which sends the bases and requests their chunks; - if the local set is not empty,
copy_local_chunksis spawned.
Step 2 comes before step 4 on purpose: the sender starts reading and
streaming as soon as the request lands, while the receiver’s disk fills in
the rest and the signatures are computed. If the remote set is empty but the
local set is not, the receiver still sends an empty NeedChunks, so the
sender may move on. pending counts every remote chunk from the start,
whichever request carries it, so the file cannot complete before its last
request has even been sent.
Bases and operations
file_io::offer_bases runs as one task per file. For each chosen chunk it
reads the region from the old file’s descriptor, outside every lock, signs it
(delta::Basis::sign: blocks of sqrt(region) bytes clamped to 512 B ..
4 KiB, per block a 32-bit rolling sum and the first 8 bytes of the block’s
BLAKE3 hash), and sends it as a ChunkBasis. The bases go out in batches of
at most 64, each batch followed by the NeedChunks for its chunks, and a
session holds at most 32 MiB of bases that are sent but not yet requested. A
region that cannot be read ends the signing, and the chunks left over are
requested raw. The control stream is ordered, so the sender holds every basis
before it sees the request that uses it.
On the sender (sender::on_basis, data_stream::payload) a basis is kept per
file and chunk until the request for that chunk arrives, then handed to the
data-stream task. For such a chunk the task runs delta::encode: a window of
one block slides over the chunk’s bytes one byte at a time, the rolling sum is
updated in place, and each position is checked against a 64 Ki-bit filter,
then the signature map, then the strong hash. A hit emits a copy of that
block’s range in the old file and jumps a block ahead; a miss extends the
current literal. Adjacent copies and literals are coalesced. If the operations
are not at least a quarter smaller than the chunk, the chunk’s bytes go
instead; otherwise the DataChunk carries ops and no data. A chunk
requested a second time has no basis any more and goes raw.
On the receiver, read_range sees a frame with operations and calls
rebuild. The operations must add up to exactly the chunk’s length, checked
before anything is read; literals are copied in, and copies are read from the
old file’s descriptor with positioned reads, outside the writer lock. The
result goes through the same write_chunk as every other chunk. A rebuild
that fails for any reason (an operation list that does not add up, a copy past
the old file’s end, a read error) or a rebuilt chunk that does not hash to
its record leaves the chunk missing, and the re-request asks for
it raw. Nothing in this path is trusted: the old file may have changed in
place since it was signed, the strong hash is 8 bytes, the sender may be
hostile, and each of these ends in a chunk that does not verify and is asked
for again.
Two fillers, one writer
The network side (accept_streams, read_stream, read_range). Each
data stream’s header names the session, the file and a run of chunks. The
reader looks up the route, reads chunk by chunk (rebuilding one that arrived
as operations), hashes each, takes the writer lock and calls
FileWriter::write_chunk, which checks length and hash again and writes at
the chunk’s offset.
The local side (copy_local_chunks) walks the local set in order. For
each chunk it reads the bytes from the source file with a positioned read,
outside the writer lock, so network chunks keep landing meanwhile; then it
locks the slot, stops if the slot is empty (the writer was retired by a newer
chunk list or a failure), and calls the same write_chunk.
A local chunk is thus verified against the sender’s hash exactly like a network chunk, and both fillers set the same verified bit. Writes from the two sides land at disjoint offsets; the lock serialises only the writes, never the reads or the network. A local chunk that fails (the source vanished or shrank, a read error, a hash mismatch because the source was changed in place without a new mtime) is logged at debug level and skipped; its bit stays clear.
Completion
Both fillers end through finish_unit: a stream reader with the number of
chunks its run accounted for, delivered or not; the copy task once, with one
unit, after its whole list. finish_unit subtracts the units from pending
and notes whether this call brought it to zero, then locks the slot:
- an empty slot means the writer was retired or already reported: nothing to do;
- if no chunk is missing, it takes the writer out of the slot and reports the file ready, and the receiver finalizes it;
- else, if this call drained
pending, it reports the file drained; - else another unit is still running and will report.
Taking the writer out of the slot makes a late unit harmless: a stream that straggles in after the file is complete finds the slot empty.
Recovery
A drained file with chunks still missing reaches Receiver::on_drained. It
reads the missing set from the writer, checks that pending is zero, counts a
re-request against MAX_REREQUESTS (3), adds the missing count back onto
pending, and sends NeedChunks for those chunks, without bases. The sender
delivers them raw and the normal path verifies them.
This is the path for a data stream that ended short, and the local copy task
and the rebuild from operations use it too, by being units of the same
request. A stale local source or a stale basis therefore costs one round trip
and the bytes of the chunks that did not verify, and the file still ends with
a verified whole-file hash. The stale index row is not corrected here; the
next scan of that source file replaces it. A file still incomplete after
three re-requests fails with WRITE_ERROR.
Finalize
file_io::finalize runs fsync (only with --fsync, or on a push into an
export with fsync = true), compares the whole-file hash with the
sender’s, applies metadata through the descriptor, renames the .part over
the destination, records the file in the index and sends FileAck DONE.
The hash is not computed by reading the .part back. BLAKE3 is a Merkle tree
over 1 KiB leaves at absolute offsets, and the writer folds the file’s hash
from the chunks it verified (tree_hash::TreeHash): the leaf-aligned interior
of each chunk is hashed as aligned power-of-two subtrees through the blake3
crate’s hazmat API, the up to 1,023 bytes at either end of a chunk wait
until the neighbouring chunk completes their leaf, sibling nodes merge eagerly
so that a few dozen chaining values are held at most, and the root is folded
at finalize along the tree’s own split points. A chunk adopted from an earlier
.part or a clone is read once to verify it and feeds the tree from that
read; a sparse hole feeds its zeros. The result equals b3sum of the file.
What finalize does not catch is a byte changed on disk after the verified
write, which rsync does not catch either.
Settle in place
When open_writer returns Opened::Identical, the content is already there,
and the file is settled in place rather than placed. The receiver sends an
empty NeedChunks, which tells the sender to wait for the acknowledgement,
emits the held-back -i line if any attribute differs, and spawns
settle_identical. That task discards a leftover .part of an earlier
attempt with its progress record, unless another writer holds it, applies the
sender’s mode, ownership and times to the existing inode through the open
descriptor, and records the file in the index with the sender’s digest, so
that the next run’s quick check passes. The receiver then acknowledges DONE.
The file counts as a metadata-only update: no bytes, no placed file. A
metadata failure fails the file like a write error, and the next run tries
again. A touch on either side, or a restore from backup, comes to one read
of the old file on the side whose index row was stale, four small control
messages and no write. The sender takes the count of files transferred from
the receiver’s SessionDone, so a push that only settles files in place
reports zero files transferred. Under -c no index row is trusted on either side, so
every file present on both sides takes this path, read once per side.
Where the bytes land: a cloned .part, in place, or appended
By default the .part is a separate file, renamed over the destination at the
end. Three variations change where the bytes are written.
A cloned .part. open_writer hands FileWriter::open_from the old
file’s descriptor and chunk list whenever the old file is still the one that
was hashed. An empty .part is first cloned from it with FICLONE
(recv::reflink): btrfs, XFS, bcachefs, ZFS with block cloning. On success
every chunk the old list holds at an offset where the new list wants the same
chunk is read, verified and fed to the tree hash (adopt_from), and neither
copied nor written. Only changed and moved chunks are written, and only those
take new space. A refused clone (tmpfs, ext4, another device with
--partial-dir) costs only the attempt, and the .part starts empty. A
.part that already holds bytes is not cloned over; its recorded chunks are
adopted as in step 3 of Open and partition.
In place (--inplace). FileWriter::open_inplace locks the destination
itself, checks that it is the hashed inode, adopts the old chunks at unchanged
offsets the same way, grows the file at once and shrinks it only at finalize,
which also skips the rename. Reads of the old content and writes of the new
one share a file, so writes are ordered by a gate on the route: admit(idx)
waits until every chunk before idx is settled (written, rejected, or given
up by a stream that ended early), and settle(idx) advances the cursor. A
chunk below the cursor is admitted at once, which is how a re-request
rewrites it. Both fillers go through the gate, and a retired writer closes it,
releasing every waiter. The old content is used only at or above the chunk
being written: a local copy whose old offset is below the chunk’s new offset
becomes a remote chunk, and a basis starts at the chunk’s own offset. That is
rsync’s rule, with rsync’s consequence: a deletion near the start keeps its
reuse, an insertion loses it. An in-place file gets one ascending request
after its bases, so the sender opens its runs in order and the one the cursor
needs is never behind the others. What --inplace costs, as in rsync:
readers see a torn file during the transfer, a crash leaves a mixture of old
and new, a whole-file hash mismatch leaves the destination inconsistent until
the retry, hard links to the destination see the new content, and a file has
one write front, the gate’s cursor.
Append (--append; planner decision Append, action APPEND). The
sender’s list covers only the tail. open_writer awaits the old file’s hash,
requires it to be the planned prefix (its length equals the tail’s first
offset, and the inode is unchanged), and builds the full list from the old
chunk list plus the tail, with no whole-file hash to compare: finalize
returns the hash folded from the bytes, which goes into the index, so the
next run quick-checks the file. Chunk indices on the wire are the sender’s,
relative to the tail. A destination that is not the planned prefix fails the
file with a message naming append. --append-verify is the ordinary DELTA
path with the planner’s skip rule, so a changed head is repaired.
The itemize line of a DELTA file
The planner decides DELTA before anyone knows whether the content changed,
so for a DELTA file it does not print the -i line at plan time. It
computes two lines, the transfer as planned and the attributes-only line that
applies if the content proves unchanged (none if no preserved attribute
differs), and the receiver prints the first when it opens the .part and the
second when it settles the file in place. A touched file therefore itemizes as
.f..t......, as in rsync. A dry run requests nothing, so the planner
itemizes at once. A file of a resumed plan carries no held-back line.
The chain
For a large file with a small change and a warm index, where S is the time of one full pass over the file on either disk:
| Phase | Done one after another | As the receiver runs it |
|---|---|---|
| Sender’s digest | S | S, concurrent with the old file’s hash |
| Receiver’s hash of the old file | S (0 if cached) | overlapped with the sender’s digest |
Local copy into the .part | S, before the request | concurrent with the transfer |
| Network transfer | after all of the above | right after the index lookups |
| Whole-file check | S, reading the .part back | none: folded from the verified chunks |
| Bytes for a small change inside a chunk | the chunk (64 KiB .. 1 MiB) | about a block (512 B .. 4 KiB) of literal, plus about 4% of the chunk in signatures the other way |
| Writes of unchanged chunks | S, copied into the .part | none with a cloned .part or in place; a read of them for the tree hash |
| Free space for a changed file | its full size | the changed chunks (clone) or none (in place) |
Done one after another, the critical path is up to 4 S plus the transfer. As the receiver runs it: S for the concurrent hashes, plus the longer of the local copy and the transfer. The receiver reads the old file once for its hash and once more, only around the missing chunks and capped at the old file’s size, for the signatures; it writes the new one once.
Receiver I/O for the same case, in reads and writes of the file’s size:
| Reads | Writes | |
|---|---|---|
| rsync, default | 2 | 1 |
rsync --inplace | 1 | changed blocks only |
irsync, cloned .part, old file’s hash cached | 1, verifying the clone’s chunks | changed chunks only |
irsync, cloned .part, old file’s hash not cached | 2 | changed chunks only |
irsync --inplace | 1 or 2, as above | changed chunks only |
irsync, plain .part (no clone support) | 1 or 2, as above | 1 |
Invariants
- A request cannot miss its streams. The route is in the table before
NeedChunksleaves the receiver. - Every chunk is verified once, by the same code, whatever its source.
write_chunkis the only way into the.part. - Nobody reports twice. A ready file’s writer leaves the slot; only the
call that brought
pendingto zero reports a drained file; a re-request raisespendingbefore the new streams arrive. - The old file is read at most once per session for its hash. The early hash is awaited before the lookup; any later hash of it is a cache hit.
- Local data is never trusted. A mismatch degrades to a network fetch,
not an error, and never reaches the
.part. - Operations are never trusted either. A chunk rebuilt from them is
verified by
write_chunklike any other; the old file is only read, through a descriptor opened once; a rebuild that fails leaves the chunk missing, and its re-request carries no basis. - A cloned chunk is verified before it counts. Each adopted chunk is read
and hashed before its bit is set, as a resumed
.part’s chunks are. - In place, nothing above the cursor is written before it is read. Writes ascend through the gate; old content is read only at or above the chunk being written; a rejected or undelivered chunk settles the gate, so the cursor never waits for it.
- An append never guesses the prefix. The sender’s tail is accepted only
when the destination is the exact inode and length that was planned;
otherwise the file fails, and a run without
--appendrepairs it. - Reconnects and failures are safe. A new chunk list bumps the generation
and retires the writer. A copy task of the old generation finds the slot
empty and stops; its late
finish_unithas nothing to report. - The sender’s view stays simple. It answers every
NeedChunkswith data streams; the bases are optional extras it may use for the one request that follows them. A file settled in place looks to the sender like one whose every chunk was adopted: an empty request, thenDONE. - Settling in place trusts the quick check, not the clock. The destination
is settled only if
fstaton the open descriptor matches the stat under which it was hashed, in size, mtime, ctime, device and inode; otherwise it is received as a delta.
The tests that pin these properties are listed in Testing.
Introduction to fileset
fileset checks that a copy of a directory tree is the same as the original.
You use it for two things:
- Verify transfers and backups made with other tools, such as rsync or rclone.
- Check important data sets in storage for bitrot. Bitrot is data that changes on disk without anyone writing to it.
fileset is a separate tool, and you do not need irsync to use it. What
it records and checks is its own code, not irsync’s. That is on purpose: a
check made with the same code as the copy can repeat the copy’s mistakes. The
one part they share is the wildcard matcher of fileset list. This part of the book assumes you
have never used irsync.
The idea
You record a manifest of the tree once. A manifest is a small database that
holds each file’s checksum and metadata. Later you check a tree against it.
fileset lists every difference. It changes nothing.
fileset init ~/Photos record a manifest of the tree
fileset check <copy> compare a copy, or the same tree later, with it
fileset update ~/Photos bring the manifest up to date after real changes
fileset list ~/Photos print what the manifest holds
The manifest is a file named .fileset.sqlite at the top of the tree. A
copy tool that copies the whole tree copies the manifest too, so the copy can
check itself.
Install
fileset comes in the same packages as irsync, so every way of installing
irsync installs it too. The quickest is the install script:
curl --proto '=https' --tlsv1.2 -LsSf https://irsync.org/install.sh | sh
Until the first stable release, v0.1.0, is out, add --beta straight after
sh -s --. The script puts the programs in ~/.local/bin and the man pages
in ~/.local/share/man, so man fileset works. If ~/.local/bin is not on PATH, it says how to add it; on Linux, logging
out and in again is usually enough. To remove it all, run it with
--uninstall (and --beta, until v0.1.0).
Homebrew (brew install irsync-dev/tap/irsync) and apt and dnf
(dist.irsync.org) work the same way from v0.1.0
on. The tarballs on the
GitHub Releases page work
too. All of them cover Linux on x86_64 and arm64 and macOS on Apple Silicon.
On other machines, build fileset from source. This needs Rust; get it from
https://rustup.rs.
cargo install --git https://github.com/irsync-dev/irsync fileset
cargo install installs no man pages.
Install it on every machine where you want to run a check.
Where to go next
- Tutorial: record a manifest, copy with
rsync, check the copy. - Verify an rsync or rclone transfer
- Verify an irsync transfer
- Check data for bitrot
- Keep a manifest current
- Reference: every command, option, output line and exit code.
- How fileset works: what a manifest records, and what
filesetcannot catch.
Tutorial: check a copy made with rsync
You will make a small tree of three files, record a manifest of it, copy the
tree with rsync -a, check the copy, and then see what a damaged copy looks
like. It takes a few minutes. You need fileset
(install) and rsync.
Everything happens in two throwaway directories, ~/fileset-demo and
~/fileset-demo-copy. Nothing here touches your real files or backups.
1. Make a tree and record a manifest
mkdir -p ~/fileset-demo/2026/01
printf 'first photo\n' > ~/fileset-demo/2026/01/IMG_0001.jpg
printf 'second photo\n' > ~/fileset-demo/2026/01/IMG_0002.jpg
printf 'third photo\n' > ~/fileset-demo/IMG_0003.jpg
find ~/fileset-demo -exec touch -d '2026-01-15T12:00:00Z' {} +
fileset init ~/fileset-demo
The touch gives every item an old modification time, as a real tree would
have. (Without it, the directories’ times and the copy’s would fall in the
same second, and rsync does not copy a directory’s time when only the
fraction of a second differs. The check in step 3 would then show CHG lines
for the directories. See the same-second note.)
fileset init hashes every
regular file and writes ~/fileset-demo/.fileset.sqlite. It prints a summary
on stderr:
entries=7 hashed=3 reused=0 warnings=0
The seven entries are the root, two directories, three files and the manifest. The manifest lives inside the tree. That matters in the next step.
2. Copy the tree
rsync -a ~/fileset-demo/ ~/fileset-demo-copy/
The manifest is an ordinary file, so rsync copies it too. If you leave it
out with --exclude .fileset.sqlite, the copy has no manifest. Then point
--manifest at the original when you check (see step 3).
3. Check the copy
fileset check ~/fileset-demo-copy
A clean copy prints nothing on stdout, a summary on stderr, and exits with code 0:
added=0 deleted=0 changed=0 unchanged=7 warnings=0
If the copy has no manifest, use the original’s:
fileset check --manifest ~/fileset-demo/.fileset.sqlite ~/fileset-demo-copy
The manifest then shows up as DEL .fileset.sqlite, because the copy lacks
the file. That one line is expected:
added=0 deleted=1 changed=0 unchanged=6 warnings=0
DEL .fileset.sqlite
4. See a difference
Damage the copy on purpose. This flips one byte of a file, so the size stays the same, and puts the old modification time back, as bitrot would. It also deletes a file and adds one:
printf 'X' | dd of="$HOME/fileset-demo-copy/IMG_0003.jpg" bs=1 seek=2 conv=notrunc
touch -r ~/fileset-demo/IMG_0003.jpg ~/fileset-demo-copy/IMG_0003.jpg
rm ~/fileset-demo-copy/2026/01/IMG_0002.jpg
echo n > ~/fileset-demo-copy/new.jpg
fileset check ~/fileset-demo-copy
Each difference is one line on stdout, and the exit code is 1:
CHG 2026/01 mtime=2026-01-15T12:00:00.000000000Z→2026-11-10T21:10:56.879697180Z
CHG IMG_0003.jpg blake3=d7e964217db4d891f80f8add25b9a5b1f82d11d135a7188db527f3af6cdaa802→266b8cdd39a8f500d03472f37ce533e3a4efbc9be56a4435ed771f892324bc80
ADD new.jpg kind=file
DEL 2026/01/IMG_0002.jpg
The hashes are the real ones for these file contents, so you should see the same. The time on the first line is when you ran the commands.
CHG IMG_0003.jpg shows blake3 alone: the content changed and nothing else
did. That is how bitrot looks. CHG 2026/01 is a side effect of the rm:
deleting a file changes its directory’s modification time. ADD is on disk
but not in the manifest. DEL is in the manifest but not on disk. CHG
shows each differing field as stored→observed. fileset reports and
repairs nothing. To repair, copy the good files again.
When you are done, remove the two directories: rm -r ~/fileset-demo ~/fileset-demo-copy.
Next: verify an rsync or rclone transfer in daily use, or check for bitrot.
Verify an rsync or rclone transfer
Use this to prove that a copy made by rsync, rclone, cp or another tool
matches the original. The examples copy ~/Photos to /mnt/backup/Photos.
For a first run, see the tutorial. Every option is in the
reference.
The steps
Record the manifest before you copy:
fileset init ~/Photos
Copy, and wait for the copy tool to finish:
rsync -a ~/Photos/ /mnt/backup/Photos/
Check the copy, on the machine that holds it:
fileset check /mnt/backup/Photos
Exit code 0 means the copy matches. Exit code 1 means it differs, and each difference is a line on stdout. Exit code 2 means the check itself failed.
If you changed the tree since you recorded the manifest, run
fileset update ~/Photos first, then copy again. See
Keep a manifest current.
The manifest is part of the tree
init writes .fileset.sqlite into the tree, so the copy tool copies it
along. If you filter the copy, for example with rsync --exclude, the manifest
may stay behind. Then check stops with no manifest found. Point
--manifest at the original’s manifest:
fileset check --manifest ~/Photos/.fileset.sqlite /mnt/backup/Photos
The copy lacks the manifest file, so the output includes DEL .fileset.sqlite.
Ignore that one line. If the original is on another machine, copy the
manifest file over first.
To keep the manifest out of the tree altogether, record it elsewhere with
fileset init --manifest <MPATH> ~/Photos and pass the same --manifest to
every check.
Tools that do not keep all metadata
The default check compares content, type, symlink targets, device numbers, permissions, modification times and sizes. A tool that does not keep permissions or times makes every file look changed. That is not damage. It is a copy that carries less metadata.
cp -r without -p keeps neither permissions nor times. The check shows a
CHG line for every file and directory:
CHG 2026 mtime=2026-11-10T19:44:21.606059787Z→2026-11-10T19:44:39.596886187Z
CHG 2026/01 mtime=2026-11-10T19:44:21.607204393Z→2026-11-10T19:44:39.596918066Z
CHG 2026/01/IMG_0001.jpg mtime=2026-11-10T19:44:21.607204393Z→2026-11-10T19:44:39.596918066Z
CHG 2026/01/IMG_0002.jpg mtime=2026-11-10T19:44:21.607204393Z→2026-11-10T19:44:39.596944775Z
CHG IMG_0003.jpg mtime=2026-11-10T19:44:21.607204393Z→2026-11-10T19:44:39.596966804Z
Here only mtime differs, because the umask on that machine left the
permissions alone. On another machine mode= shows up too. rclone keeps
permissions on few backends, and keeps modification times to a precision that
depends on the backend, so expect the same kind of lines after an rclone copy.
Compare only what the tool can keep. Drop one field at a time:
fileset check --ignore mtime /mnt/backup/Photos
fileset check --ignore mode --ignore mtime /mnt/backup/Photos
Or use the relaxed tier, which compares type, content, symlink targets and device numbers only:
fileset check --relaxed /mnt/backup/Photos
added=0 deleted=0 changed=0 unchanged=7 warnings=0
Content is still compared in every tier, so a changed byte still shows. Add
back what you can trust, such as --relaxed --require size. The tiers are
explained in How fileset works.
Directory times in the same second
rsync compares a directory’s time only to the whole second. If the copy’s
directory was changed in the same second as the source’s, rsync treats them
as equal and never sets the time. This happens when you build a tree and copy
it right away. Files are not affected: their times are compared exactly.
The check then shows lines like this, where both times share the same second:
CHG 2026/01 mtime=2026-11-10T21:10:56.123456789Z→2026-11-10T21:10:56.987654321Z
This is harmless: no content differs. Running rsync -a again does not fix
it. Either leave the time out with --ignore mtime on that check, or give the
source directories an older time before you copy, for example with
touch -d '2026-01-15T12:00:00Z'. Write the time with the Z so that GNU,
macOS and uutils touch all read it the same way.
When the copy is not on a local disk
fileset reads a local path. It cannot check an rclone copy that lives in
S3 or another object store.
- Mount the remote and check the mount point:
rclone mount myremote:photos /mnt/remote, thenfileset check --relaxed --manifest ~/Photos/.fileset.sqlite /mnt/remote. Every file is read over the network, so this is slow on a big tree. - Or run
fileset checkon a machine that holds the copy as ordinary files.
Object stores do not keep permissions, owners or symlinks as a file system
does, so use --relaxed there.
Other things that make a check differ
- Run the check after the copy tool has finished. An interrupted
rsyncleaves temporary files behind, andcheckreports them asADD. - Copy deletions too. Without
rsync --delete, files you removed from the original stay in the copy and show asADD. - Between macOS and Linux, symlink permissions differ. Use
--ignore mode.
Verify an irsync transfer
Use this when you want proof, from a tool that does not check with irsync’s
code, that a tree arrived intact. (For rsync, rclone and other tools, see
Verify an rsync or rclone transfer.) You record a manifest of the tree on the client,
let irsync carry the tree and the manifest to the daemon, and check the copy
against the manifest there. The same manifest later tells you whether either
copy has rotted on disk.
The examples use the setup from Your first sync:
the client has ~/Photos, and the server runs the daemon, known on the
client as myserver, with the export photos at /srv/photos. Every
option is listed in the fileset reference.
Install fileset
Install fileset on both machines (see
Introduction):
cargo install --git https://github.com/irsync-dev/irsync fileset
1. Record a manifest on the client
On the client, create the manifest:
fileset init ~/Photos
This hashes every regular file and writes ~/Photos/.fileset.sqlite. At the
end it prints a summary on stderr:
entries=1843 hashed=1790 reused=0 warnings=0
If you have recorded a manifest before, bring it up to date instead. Only files whose size, modification time or inode changed are hashed again:
fileset update ~/Photos
2. Sync
Push the tree, manifest included:
irsync -av ~/Photos/ myserver:photos/
The manifest is an ordinary file in the tree, so irsync carries it like any
other. If you removed files on the client since the last sync, add
--delete, or the daemon’s copy keeps them and the check reports them as
ADD.
Wait until the sync has finished. An interrupted sync leaves
.irsync.<name>.part files behind (see
Files and state), and the check reports
those too.
3. Check on the daemon’s machine
On the server, check the copy against the manifest that arrived with it. Run this as an account that can read every file, such as the account the daemon runs as:
fileset check /srv/photos
A clean copy prints nothing on stdout, a summary on stderr, and exits with code 0:
added=0 deleted=0 changed=0 unchanged=1843 warnings=0
Otherwise each difference is one line on stdout, and the exit code is 1:
CHG 2026/01/IMG_0042.jpg blake3=9f2c41e0b7a35d68c1f04e2b9a7d3c5e8f1b6a0d4c2e7f93b5a8d1c6e0f4b297→51d07a3e9c2b4f8d6e1a0c5b7f3d9e2a4c8b6f0d1e5a3c7b9f2d4e6a8c0b1d35
DEL 2026/01/IMG_0043.jpg
ADD is on disk but not in the manifest, DEL is in the manifest but not on
disk, and CHG shows each differing field as stored→observed.
The default comparison covers type, content, symlink targets, device numbers,
permissions, modification times and sizes. Owners are not compared by
default: -a keeps the owner only when the daemon runs as root, and maps user
and group names to the daemon’s ids unless you pass --numeric-ids. When both
machines use the same ids, compare owners as well:
fileset check --require uid --require gid /srv/photos
If the client runs macOS and the server Linux, or the other way round, symlink permissions differ between the two systems. Leave them out:
fileset check --ignore mode /srv/photos
Repair a damaged copy
If a later bitrot check finds a damaged file, fileset repairs
nothing. A normal sync does not repair such a file either, because it compares
size and modification time. Copy the good version from the other machine with
-c, which compares content. If the server’s copy is damaged, push again:
irsync -avc ~/Photos/ myserver:photos/
If the client’s copy is damaged, pull instead:
irsync -avc myserver:photos/ ~/Photos/
Check the other copy first, so that you do not spread the damage. To find damage in the first place, see Check data for bitrot.
Check data for bitrot
Bitrot is data that changes on disk without anyone writing it: a flipped
bit, a bad sector, a faulty controller. The file’s size and modification time
stay the same, so most tools do not notice. fileset reads every byte again
and compares it with the checksum it recorded.
The examples use ~/Photos. Every option is in the reference.
Record, then check later
Record a manifest while you know the data is good:
fileset init ~/Photos
Months later, run check. No copy is involved:
fileset check ~/Photos
A file whose bytes changed while its size and modification time stayed the
same shows up as a CHG line with blake3 alone:
CHG 2026/01/IMG_0001.jpg blake3=81c4b7f7e0549f1514e9cae97cf40cf133920418d3dc71bedbf60ec9bd6148cb→7d271ea55b6b5af8d6a863e4530228f65ffc4a33086a485d73e84ee84243463f
fileset reports; it repairs nothing. Restore the file from another copy,
and check that copy first so that you do not spread the damage.
Rot or an edit?
Rot usually shows as a CHG line with blake3 alone, while an edit changes
the time and size too. Check before you update
explains how to tell them apart and why the order matters.
Check on a schedule
check exits 0 when clean, 1 when it found differences and 2 when the run
itself failed. A cron job can use that. This line checks at 03:00 on the first of each
month. It writes everything to a log, and prints a message, which cron mails
to its owner, only when the check did not exit 0:
0 3 1 * * $HOME/.cargo/bin/fileset check -q $HOME/Photos > $HOME/fileset-check.log 2>&1 || echo "fileset check exited with $?; see $HOME/fileset-check.log"
Cron has a short PATH that does not include ~/.cargo/bin, so the line
gives the full path to fileset. Cron runs the command with sh, which
expands $HOME; it does not expand ~ everywhere, for example not in PATH=
lines, so write $HOME or the full path. The mail only arrives if local mail
is set up on the machine.
-q hides progress. The summary line still goes to stderr, which is why the
log takes both streams. Add --fail-on-warnings when an unreadable file
should count as a failure too. Warnings alone give exit 0 otherwise.
Exit 1 and exit 2 are different problems. Exit 1 means your data differs from
the manifest. Exit 2 means fileset could not run, for example because the
disk is not mounted or the manifest is missing.
Read-only media and snapshots
check never changes the tree. But a manifest inside a read-only tree may
fail to open, with exit 2 and a message suggesting --manifest. Copy the
manifest somewhere writable and point --manifest at the copy:
cp /mnt/snapshot/photos/.fileset.sqlite /tmp/photos.fileset.sqlite
fileset check --manifest /tmp/photos.fileset.sqlite /mnt/snapshot/photos
If you know the tree will end up on such media, create its manifest with
fileset init --store redb. That manifest is a single file that check
only reads, so it needs no copy. See
The redb backend.
Keep a manifest current
A manifest describes the tree as it was when you recorded it. When you add, edit or remove files on purpose, bring the manifest up to date:
fileset update ~/Photos
update hashes only files whose size, modification time or inode changed, or
that the manifest has no hash for. For every other file it keeps the stored
hash. It forgets files that are gone. The summary shows how much work it did:
entries=8 hashed=1 reused=3 warnings=0
Check before you update
Run check first on a tree you suspect, or have not looked at for a while:
fileset check ~/Photos
update keeps the stored hash of a file whose size, modification time and
inode are unchanged. So if a byte rotted in such a file, the stored hash
still holds the old content and the next check still shows the damage. But
an edited file is rehashed, and its new content becomes the truth. If rot and
an edit hit the same file, update hides the rot.
So read the check output first. A file you edited shows several fields
changed, such as blake3, mtime and size. Damage you did not cause often
shows blake3 alone. When every difference is one you meant, run update.
Record the current content as correct
update --rehash hashes every file again, even when size, modification time
and inode are unchanged:
fileset update --rehash ~/Photos
Use it only when you have decided the current content is right, for example
after you restored a file from a good copy. It takes as long as init. It
overwrites the stored hash of a damaged file, so the damage is no longer
visible.
Keep a copy’s manifest in step
After update, copy the tree to the backup again with your copy tool. The
updated manifest travels with it. Then check the copy. See
Verify an rsync or rclone transfer.
fileset reference
fileset records the state of a directory tree in a manifest and later
verifies the tree against it. A manifest is a small database that holds each
file’s checksum and metadata, so that a copy of the tree, or the same tree
later, can be checked against it. It is a SQLite file by default. There are two
other storage backends: fjall, which keeps the manifest in a directory, and
redb, a single file made to be read from media that
cannot be written to.
Introduction to fileset explains the idea and leads to the how-to guides: verifying an rsync, rclone or irsync transfer, checking data for bitrot, and keeping a manifest current.
Commands
fileset init [OPTIONS] PATH
fileset update [OPTIONS] PATH
fileset check [OPTIONS] PATH
fileset list [-v] [--manifest MPATH] PATH [PATTERN]
PATH is the root of the tree and must be a directory.
init
init scans the tree and creates its manifest, at PATH/.fileset.sqlite
by default. It refuses to run when:
- a manifest already exists. The exception is a manifest left by an
initthat was interrupted (killed, or the machine went down): it holds nothing, soinitreplaces it with a warning. - the tree lies inside another fileset: a
.fileset.sqlite,.fileset.fjallor.fileset.redbexists in a parent directory ofPATH. This is checked before anything is written. - the tree holds a manifest in a subdirectory. This is found when the scan
reaches it;
initthen removes the manifest it had begun.
Nested filesets are not supported. If the scan fails, init removes the
manifest it began.
update
update scans the tree and brings an existing manifest up to date. It
refuses to run if there is no manifest, or if the manifest was left by an
interrupted init (run init again). A manifest in a subdirectory is a
warning, not an error.
A regular file is hashed again only when its size, mtime or inode differ
from the manifest (on Windows, the file index stands for the inode), or when
the manifest holds no hash for it. Otherwise the
stored hash is kept. A file that cannot be read produces the warning
cannot hash <path> and is recorded without a hash. Rows that have not changed are not rewritten. Whatever
the scan did not see is removed from the manifest: deleted entries, and also
everything below a directory that could not be read or a mount point that was
not crossed. Each such directory and mount point produces a warning.
init and update share one engine and differ only in these preconditions.
check
check scans the tree and reports every difference between it and the
manifest. It never changes the tree or the manifest’s contents. Opening a fjall
manifest does touch its journal and lock files; a redb manifest is only read.
check hashes a regular file only when the manifest has an entry for it and
content is compared. A file the manifest holds no hash for (it could not be
read when it was recorded) produces the warning
no stored checksum for <path>. A manifest in a subdirectory produces the
warning nested manifest at <path>.
list
list prints what the manifest holds: one line per entry, with its checksum
and metadata (see Listing). fileset ls is the same command.
list reads only the manifest. It does not look at the tree, so it says what
was recorded, not whether the tree still matches; that is check. It never
changes the manifest’s contents or the tree. As with check, opening a fjall
manifest does touch its journal and lock files; a SQLite or redb manifest is
only read. With --manifest, PATH does not have to exist, so a copy of a
manifest can be listed without its tree.
With a PATTERN, only the entries whose path matches it are listed. Quote the
pattern, or the shell expands it first.
Options
All commands
| Option | Effect |
|---|---|
--manifest MPATH | Use the manifest at MPATH instead of PATH/.fileset.sqlite, PATH/.fileset.fjall or PATH/.fileset.redb. It may lie outside the tree. A directory is read as fjall, a file that starts as a redb file does as redb, any other file as SQLite. |
--fail-on-warnings | Exit 1 instead of 0 when the run produced warnings. |
--cross-mount-points | Descend into directories on other filesystems. It has no effect on Windows, where no reparse point is entered (see Windows). |
--no-dir-sort | Do not sort directory entries before iterating. |
-j, --jobs N | Threads that hash file contents. Default: the number of CPUs. N is at least 1. |
--walk-threads N | Threads that list directories and read metadata. Default: 4. N is at least 1. |
--no-builtin-excludes | Walk the built-in excludes like any other directory. |
-q, --quiet | Suppress progress. |
-v, --verbose | Print one line per entry on stdout as it is handled (see Every entry, with -v), and turn progress off. Conflicts with --quiet. |
More walk threads are often slower. On a 16-core machine with an APFS SSD, a
no-change update of a 1.7 million entry tree took 24 s with 4 threads and
30 s with 8: the kernel serialises much of the metadata work.
Without --manifest, fileset looks for .fileset.sqlite,
.fileset.fjall and .fileset.redb at the root. If more than one exists, it
stops and asks for --manifest.
A manifest found at the root must be a real file or directory. fileset
refuses one that is a symbolic link, because a tree from someone else could
point it at a manifest of yours. To keep a manifest elsewhere, name it with
--manifest; that path may be a link.
A manifest that came with a tree is not trusted. fileset refuses a
.fileset.sqlite that holds anything but plain tables and indexes, and a
.fileset.fjall directory with anything inside but files and directories. In
a .fileset.redb every entry carries a checksum, and one that does not match
is an error, not an entry.
The options above are for the commands that walk a tree. Of them, list
takes only --manifest.
init only
| Option | Effect |
|---|---|
--store sqlite|fjall|redb | Backend to create. Default: sqlite. |
--no-compaction | Leave a redb manifest as large as the run made it; see The redb backend. The other backends ignore it. |
update only
| Option | Effect |
|---|---|
--rehash | Hash every regular file again, even if size, mtime and inode are unchanged. |
--no-compaction | Leave a redb manifest as large as the run made it; see The redb backend. The other backends ignore it. |
--force-xattr-reads | Read every entry’s extended attributes. By default an entry whose type, inode, size, mtime and ctime match the manifest keeps the attributes recorded there (changing an attribute updates the ctime); only an entry whose attributes could not be read in full is read again. |
check only
| Option | Effect |
|---|---|
--relaxed | Compare the relaxed tier; see Comparison tiers. Conflicts with --paranoid. |
--paranoid | Compare the paranoid tier; see Comparison tiers. Conflicts with --relaxed. |
--ignore FIELD | Drop one field from the comparison. Repeatable. |
--require FIELD | Add one field to the comparison. Repeatable. |
list only
| Option | Effect |
|---|---|
-v, --verbose | Also print the owner, the link count, device numbers and extended attributes of each entry. |
Comparison tiers
| Tier | Compared |
|---|---|
--relaxed | type, content (blake3), symlink target, device numbers (rdev) |
| default | relaxed, plus mode, mtime, size |
--paranoid | default, plus uid, gid, nlink, xattr |
The type is always compared. --ignore and --require adjust whichever tier
is in effect, so “default plus owner” is --require uid --require gid. Field
names:
blake3 target rdev mode mtime size uid gid nlink xattr
An unknown field name is an error (exit 2).
Some fields apply only to some types:
blake3applies to regular files,targetto symlinks,rdevto character and block devices.sizeandnlinkare not compared for directories.mtimeis not compared for the root, nor for the directory that holds the manifest when the manifest lies inside the tree: writing the manifest changes both.- A manifest inside the tree is recorded, but only its type is compared.
Output
check writes one line per differing entry to stdout:
ADD docs/new.txt kind=file
DEL docs/old.txt
CHG docs/a.txt mode=0644→0600 size=12→13
ADD: on disk, not in the manifest.kindis one ofdir,file,symlink,fifo,socket,chardev,blockdev,other.DEL: in the manifest, not on disk. This includes everything recorded below a directory that is now a file or a symlink.CHG: in both, with at least one compared field differing. Each field is shown asfield=<stored>→<observed>. If the type differs, onlykind=is shown.CHG <path> kind=<stored kind>→unverified: recorded in the manifest, butcheckcould not observe it. It lies below a directory that could not be read or a mount point that was not crossed, or it could not be stat’ed. Content that cannot be verified counts as a difference (exit 1), not just a warning.
Field values:
| Field | Shown as |
|---|---|
blake3 | 64 hexadecimal digits; unreadable when the file could not be read |
mode | four octal digits, such as 0644 or 4755 |
mtime | UTC with nanoseconds, such as 2026-01-31T12:00:00.000000005Z |
size, uid, gid, nlink, rdev | decimal |
target | the link target; - if none |
xattr | one xattr:<name>=<stored>→<observed> per attribute that differs; - where the attribute is absent; values longer than 64 bytes are cut and end in … |
Paths, link targets and attribute names and values are escaped. Printable
UTF-8 and the space pass through, \ becomes \\, control bytes, DEL and
bytes that are not valid UTF-8 become \xNN, and C1 controls and the bidi
formatting characters become \u{...}.
Every entry, with -v
With -v, every entry gets a line on stdout, in the order it is walked and
as soon as it is handled. check adds two kinds of line to the ones above:
| Prefix | Meaning | Printed |
|---|---|---|
EQL | in both, every compared field matches | -v only |
CHG | in both, something differs | always |
ADD | on disk, not in the manifest | always |
DEL | in the manifest, not on disk | always |
SKP | skipped on purpose | -v only |
EQL 2026/01/IMG_0001.jpg kind=file size=48213 mtime=2026-01-15T12:00:00.000000000Z mode=0644 blake3=81c4b7f7e0549f1514e9cae97cf40cf133920418d3dc71bedbf60ec9bd6148cb
CHG 2026/01/IMG_0002.jpg mode=0644→0600
ADD new.jpg kind=file
SKP .Spotlight-V100 reason=builtin-exclude
DEL old.jpg
init and update print nothing on stdout without -v. With it, they use
the same prefixes for what happened to the manifest:
| Prefix | Meaning |
|---|---|
ADD | new entry recorded |
CHG | entry changed in a way check could report |
EQL | nothing check could report changed |
DEL | entry dropped: the path is gone or is no longer walked |
SKP | skipped on purpose |
EQLincheck, andADD,CHGandEQLininitandupdate, show the entry in full:<path> kind= size= mtime= mode=, thenblake3=when the entry has a checksum.checkshows what is on disk;initandupdateshow the entry as now recorded.blake3=is left off for anything that is not a regular file, for the manifest itself, for a file that could not be read, and in acheckthat does not compare content (--ignore blake3).SKP <path> reason=builtin-exclude: one of the built-in excludes was skipped.DELlines come after the walk, incheckand inupdate.- In
update,CHGcovers every fieldcheck --paranoidcompares, and a checksum gained or lost. The root’s mtime and a manifest inside the tree change whenever the manifest is written;checkdoes not report that, so both show asEQL. - In
update,DELis also printed for entries that are still on disk but no longer walked: those below a built-in exclude, and those below a directory that could not be read.
grep -v '^EQL' leaves what differs.
Listing
list writes one line per manifest entry to stdout, and nothing to stderr:
$ fileset list ~/Photos '2026/**'
2026/01 kind=dir size=4096 mtime=2026-01-31T12:00:00.000000005Z mode=0755
2026/01/IMG_0001.jpg kind=file size=48213 mtime=2026-01-15T12:00:00.000000000Z mode=0644 blake3=81c4b7f7e0549f1514e9cae97cf40cf133920418d3dc71bedbf60ec9bd6148cb
2026/latest kind=symlink size=15 mtime=2026-01-31T12:00:00.000000005Z mode=0777 target=01/IMG_0001.jpg
The line is the one check -v prints for an entry, without a prefix:
<path> kind= size= mtime= mode=, then blake3= when the entry has a
checksum. A symlink also shows target=. The root of the tree is listed as
..
With -v, each line continues with uid=, gid= and nlink=, then rdev=
for a character or block device, then one xattr:<name>=<value> per extended
attribute, in name order. A value longer than 64 bytes is cut and ends in
….
Entries come in the order the manifest stores them: by path, compared byte by
byte. Uppercase sorts before lowercase and img10 before img9. A directory
is followed by its contents, except that a neighbour whose name goes on with
a character that sorts before / (a space, -, ., + or ,) comes in
between:
2024
2024-old
2024.txt
2024/a.jpg
The pattern is matched against the whole path below the root:
| In the pattern | Matches |
|---|---|
* | any run of characters except / |
** | any run of characters, / included |
? | one character except / |
[abc], [a-z] | one of these characters; [!a-z] or [^a-z]: any other, except / |
\ and a character | that character itself |
| anything else | itself |
So '*.jpg' lists the top level only, '**/*.jpg' every level below it,
'2026/**' everything under 2026, and 2026 that one entry: a pattern
that matches a directory does not list what is inside it. Upper and lower
case differ. Trailing slashes and a leading ./ are ignored, so 2026/
means 2026. No pattern is an error; one that matches nothing prints
nothing. The wildcards are those of irsync’s --exclude patterns, but here
a pattern always covers the whole path: there, *.jpg matches at every
level and a leading / ties a pattern to the top.
When its reader stops early, as in fileset list ~/Photos | head, list
ends without an error.
Warnings and summary
Warnings go to stderr, prefixed WARN . Progress goes to stderr only when
stderr is a terminal and neither -q nor -v is given. A summary line goes to stderr at
the end:
added=1 deleted=1 changed=1 unchanged=40 warnings=0 (check)
entries=43 hashed=3 reused=40 warnings=0 (init, update)
Built-in excludes
The system keeps some names at the top of a volume for itself, and ordinary
users cannot read them. At the root of the tree, and at every mount point
crossed with --cross-mount-points, entries with these names are neither
recorded nor descended. Skipping one is not a warning, so it does not trip
--fail-on-warnings. The same names deeper in the tree are ordinary entries.
On Unix the names are the ones macOS keeps at the top of every volume it
touches: .DocumentRevisions-V100, .Spotlight-V100, .TemporaryItems,
.Trashes and .fseventsd. They are skipped on every Unix system, macOS or
not: on a disk read elsewhere they are readable but still junk. A name must
match exactly, case included.
On Windows the names are System Volume Information, which cannot be read,
and $RECYCLE.BIN, which holds the deleted files of every user. They match
in upper, lower or mixed case, as NTFS names do. fileset enters no mounted
volume on Windows, so they are skipped at the root of the tree only. The
macOS names are ordinary entries there.
A manifest written with --no-builtin-excludes may hold them. check
without that option does not report them, and the next update without it
drops them.
Files
| Path | Contents |
|---|---|
PATH/.fileset.sqlite | The manifest, SQLite backend (default). Its -wal, -shm and -journal sidecars are skipped by the scan. |
PATH/.fileset.fjall | The manifest, fjall backend: a directory. |
PATH/.fileset.redb | The manifest, redb backend: one file, with none beside it. |
An update that finishes leaves the SQLite manifest as a single file. If
another process holds it open, the -wal sidecar stays, with a warning; the
next update folds it in.
The redb backend
fileset init --store redb keeps the manifest in one file,
.fileset.redb. It is for a manifest that travels with its tree, onto a
disc, a snapshot or a write-protected drive:
- It reads where nothing can be written.
checkandlistopen the file for reading only. They create nothing beside it and change nothing in it. The other backends write when they open a manifest, so theirs has to be copied off such media first. - It is as small as it gets. redb uses the space an
updatefrees again, but never gives it back, so the file would only grow.initandupdatetherefore compact the manifest before they finish. Afterwards it is within a hundredth of the size a newinitof the same tree gives. A million entries take about 100 MB, and compacting them under a second. - It is on disk when the command returns. The last thing
initandupdatedo is flush the manifest and close it.
--no-compaction skips the compaction. The manifest is as good, but can be
up to twice the size, because redb grows its file in large steps. The next
init or update without the option compacts it.
If init or update is killed, the manifest is left in need of a repair,
which only an open for writing can make. check and list then stop with
exit code 2 and say so. Run fileset update where the manifest can be
written, or fileset init again if it was an init that was killed. A
killed update keeps what it had recorded up to about a second before.
A redb manifest that is damaged, by a failing medium or on purpose, gives an
error. Every entry is stored with a checksum of its path and content, which
is checked whenever the entry is read, and update verifies the whole file
before it writes to it. The manifest also holds a checksum of all its entries
together. check and list compare it once they have read them all, so an
entry that damage removed is an error too. These checksums guard against
damage, not against someone who rewrites the manifest and its checksums to
match.
Exit codes
| Code | Meaning |
|---|---|
0 | Clean. For list: the entries were printed, also when none matched. |
1 | check found differences; or, with --fail-on-warnings, the run produced warnings. The second is the only way init and update return 1. |
2 | The run itself failed. |
Exit code 2 covers, among others: a manifest that cannot be opened or read;
a root that is not a directory; a manifest schema newer than this fileset;
check on a manifest schema older than this fileset (update migrates
it); more than one manifest at the root without --manifest; a manifest at the root
that is a symbolic link; init on a tree that
already has a manifest, lies inside a fileset or contains a nested one;
update on a tree that has none; check, update or list on a manifest
made on the other platform family, and check on a stored path that is not a
valid name on this platform (see Windows).
Read-only media
check never changes the tree. But a manifest inside a read-only tree, such
as a snapshot, may fail to open: fileset exits 2 with a message that
suggests --manifest. Copy the manifest somewhere writable and point
--manifest at the copy. Check data for bitrot
shows how.
A manifest made with --store redb does not need this: it
opens on read-only media as it is.
Windows
fileset runs on Windows, on x86_64 and ARM64, with the tree on NTFS. A
manifest records which family of systems made it, Unix (Linux, macOS,
FreeBSD) or Windows, and fileset uses a manifest only on the family that
made it. irsync itself does not run on Windows yet.
What a Windows manifest records
| Field | Value on Windows |
|---|---|
kind | dir, file or symlink; any other reparse point, a junction included, is other |
size | the size in bytes; 0 for a directory and for a symlink |
mtime | the last write time, in steps of 100 ns |
blake3, target | as on Unix |
ino, dev, nlink | the file index, the volume serial number and the link count |
ctime | the NTFS change time |
mode, uid, gid, rdev, extended attributes | zero or empty, so never a difference |
Those fields are zero or empty in a Windows manifest and on a Windows tree
alike, so they never differ and a check never reports a difference in mode,
uid, gid or rdev, whatever the tier. --paranoid still compares nlink.
No comparison tier uses ctime. update decides by size, mtime and file
identity whether to hash a file again, on Windows as on Unix. The change time
is not part of that, so a file rewritten with its old mtime put back is not
hashed again.
Names and paths
- A name is stored as WTF-8. A well-formed name is plain UTF-8, the same
bytes as in a Unix manifest. A name NTFS allows but UTF-16 does not, one
with an unpaired surrogate, is stored in the three-byte form UTF-8 would
use for that surrogate, so nothing is lost. Output shows those bytes as
\xNN, like any bytes that are not valid UTF-8. - Bytes that are not valid WTF-8 are an error, never repaired.
- Stored paths use
/, on Windows too. ThePATTERNoflistuses/, and\in it escapes the next character, as in the table of wildcards. - A symlink’s target is stored as the system gives it, in WTF-8, with its own separators. It is content, not a path of the manifest.
- Paths longer than 260 characters work, and so do names the shell refuses,
such as a trailing dot or space or
CON. checkstops with exit code 2, naming the path, when the manifest holds a path that is not a valid name on Windows: bytes that are not WTF-8, or a component that is not exactly one name, such as.,..,C:x, an empty one, one with a\, or one with a character NTFS does not allow in a name (< > : " | ? *or a control character;ab:cwould name a stream ofab). It does not report the path as deleted.- NTFS names are case-insensitive. A manifest can still hold two names that
differ only in case, when it was made in a case-sensitive directory; it
cannot be checked reliably in an ordinary one. If one of the two is
missing,
checkdoes not report it, because the other answers to its name. A rename that changes only the case shows as an added entry, and the old name is not reported. The same holds on a case-insensitive macOS volume. - At the root of the tree,
System Volume Informationand$RECYCLE.BINare skipped, whatever their case (see Built-in excludes).
Reparse points
fileset never follows a reparse point of any kind. It does not walk
through a symlink, a junction or a mounted volume, so --cross-mount-points
changes nothing on Windows. A symlink is recorded as symlink with its
target. A junction or a mount point is recorded as other and not entered.
A reparse point that holds a file’s data is recorded as other too, and not
hashed: a cloud placeholder (OneDrive Files On-Demand), and a file of Data
Deduplication on Windows Server, among others. A check compares little for
such an entry and never its content. Neither kind has been tested, OneDrive
included.
The rules for a manifest that came with a tree hold as well, with one change: where Unix refuses a symbolic link, Windows refuses any reparse point.
- A manifest found at the root that is a symlink or a junction is refused,
with a message that starts
<path> is a symbolic link. Name a manifest elsewhere with--manifest. - A fjall manifest with a reparse point inside is refused.
- Hashing opens a file without following a reparse point, and checks that it is not one. A link swapped in after the walk makes the hash fail; it is not the hash of another file.
A redb manifest in use
Windows makes the locks on a file mandatory. While a fileset holds a redb
manifest for writing, no other program can read it either, and a check,
list or update on it stops with <path> is open in another fileset (for
check and list, <path> is open in another fileset that is writing it).
Manifests from the other platform family
A manifest has a platform key, unix or windows. init writes it and
update keeps it, in all three backends. A manifest without the key is
refused: manifest meta key 'platform' missing.
check, update and list refuse a manifest made on the other family, with
exit code 2 and a message that starts this manifest was made on unix, and this is windows (or made on windows, and this is unix) and ends
fileset cannot use a manifest across the two yet. A platform
value other than unix or windows is refused too: manifest platform '<value>' is not known to this fileset.
What is not recorded
The read-only attribute and the security descriptor (the owner and the access control list) are not recorded, so a change to either is not reported. Nor are the other attributes (hidden, system, compressed and the rest), the creation time and alternate data streams. See What fileset cannot catch.
Not supported
ReFS, FAT and exFAT volumes, network shares, and the folders a virtual machine shares with its host are not supported.
Known limitations
- Symlink permission bits differ between Linux (always
0777) and macOS (set from the umask, often0755), so a tree carried between them showsmode=changes on symlinks. Use--ignore modeor--relaxed. - fjall preallocates a sparse 64 MiB journal in the manifest directory. Copy
a fjall manifest with a sparse-aware tool, such as
cp --sparse=alwaysorrsync --sparse, to avoid writing 64 MiB of zeros.
Holes in sparse files, hard links, ACLs, mount points, timestamp precision and the other things a check cannot see are in What fileset cannot catch.
How fileset works
This page explains what a manifest holds, what a check compares, and what
fileset cannot see. Commands and options are in the reference.
fileset lives in crates/fileset. It shares no code with irsync on the
way it records and checks a tree; only the wildcard matcher of fileset list
(the irsync-glob crate) is shared.
What a manifest records
fileset init walks the tree and records one entry for every file,
directory, symlink and other item it finds. Each entry holds:
- the path and the type: directory, regular file, symlink, fifo, socket, character device or block device;
- for a regular file, a BLAKE3 checksum of its content;
- for a symlink, its target; for a device, its device numbers;
- permissions, owner and group, size, modification time and link count;
- extended attributes, which are named values some file systems attach to a file.
The manifest is a SQLite file, .fileset.sqlite, at the top of the tree. Two
other backends exist: fjall stores it as a directory, and redb as a
single file that can be read from media that cannot be written to (see
The redb backend). The default is the one to
use unless you have a reason.
update keeps a stored checksum while a file’s size, modification time and
inode (on Windows, file index) are unchanged. That is what makes it fast, and
why you check before you update.
The change time is not part of that decision, on any system.
On Windows
fileset runs on Windows, on NTFS, and records what the two worlds share:
files, directories, content, sizes, modification times, hard links and
symlinks. A Windows manifest holds these values:
| Field | Value on Windows |
|---|---|
kind | dir, file or symlink; any other reparse point, a junction included, is other |
size | the size in bytes; 0 for a directory and for a symlink |
mtime | the last write time, in steps of 100 ns |
blake3, target | as on Unix |
ino, dev, nlink | the file index, the volume serial number and the link count |
ctime | the NTFS change time |
mode, uid, gid, rdev, extended attributes | zero or empty, so never a difference |
- Names are bytes. On Unix a name is the raw bytes of the file system. On
Windows it is WTF-8: plain UTF-8 for a well-formed name, and a lossless
three-byte form for an unpaired surrogate, which NTFS allows. A well-formed
name has the same bytes in a Windows manifest as in a Unix one. Bytes that
are not valid WTF-8 are an error, never repaired or replaced. Stored paths
use
/on both systems, and so do the patterns oflist. - Links are never followed. The walk does not enter a symlink, a junction or a mounted volume, and hashing opens a file without following a reparse point, so a link swapped in after the walk is an error and not another file’s hash. A manifest that came with a tree is held to the same rule: a symlink or a junction in its place is refused.
- A manifest belongs to one family. It records whether Unix or Windows
made it, in a
platformkey.check,updateandlistrefuse a manifest from the other family, and a manifest without the key. The message and the details are in the reference. - The path may be long. The tree’s root is resolved to the extended form
(
\\?\), so the 260-character limit does not apply. - The volume’s own folders are skipped. At the root of the tree,
System Volume Information, which cannot be read, and$RECYCLE.BIN, which holds every user’s deleted files, are neither recorded nor entered, whatever their case. See Built-in excludes. - Some reparse points hold data. A cloud placeholder (OneDrive Files
On-Demand) or a deduplicated file on Windows Server is a reparse point.
filesetrecords it asotherand does not hash it, so a check compares little for it and never its content. Neither has been tested, OneDrive included.
Comparison tiers
check compares a tree with the manifest. How much it compares depends on
the tier.
There are three tiers: relaxed (content only, plus type, symlink target and device numbers), the default (adds permissions, modification time and size) and paranoid (adds owner, group, link count and extended attributes). The table of exactly which fields each tier compares is in the reference.
Pick the tier by what the copy tool can keep. A plain cp or an rclone
copy to a backend without permissions fits --relaxed. An rsync -a copy
between machines that share user ids fits the default plus
--require uid --require gid. --ignore and --require adjust any tier one
field at a time.
The tier decides what counts as a difference. Content is compared in every tier, so changed bytes always show.
What fileset cannot catch
fileset reports differences in what it records. Some things it does not
record, or does not compare, so a copy can differ from the original and still
pass.
- Holes in sparse files.
filesethashes the bytes a program reads. A hole reads as zeros, so a sparse file and a fully written copy of it have the same checksum. A check cannot tell whether a copy kept the holes. - Hard links. Only the link count is recorded, and it is compared only
with
--require nlinkor--paranoid.filesetdoes not record which paths share a file, so a copy that turned hard links into separate files passes the default check. - ACLs on macOS. Access control lists are not recorded.
- On Windows, the read-only attribute and the security descriptor. Neither is recorded, so a change to either is not reported. The same holds for the other attributes, the creation time and alternate data streams. A copy that loses them passes the check.
- Names that differ only in case, on a file system that ignores case.
NTFS, and a case-insensitive macOS volume, find a name in any case. A
manifest made where
aandAare two names, checked where they are one, does not report a missing one of the two, and a rename that changes only the case shows as an added entry, with no deleted one. - Anything it did not look at. Mount points are not crossed unless you
pass
--cross-mount-points. A tree with btrfs subvolumes is cut short by default. A warning names the directory.checkreports what lies below asunverified, which counts as a difference.updatedrops it from the manifest. - Timestamp precision. Modification times are compared to the nanosecond.
A file system with coarser timestamps shows
mtime=changes on every file. Use--ignore mtimeor--relaxed. - A manifest that is wrong from the start.
filesetcompares against what it recorded. If the tree was already damaged atinit, the manifest records the damage.
The reference lists two more: symlink
permission bits between Linux and macOS, and the sparse journal of the fjall
backend. The reference also says which Windows
volumes are not supported: ReFS, FAT, exFAT, network shares and the folders a
virtual machine shares with its host.
fileset reports and repairs nothing, and it never changes the tree.
Set up a development checkout
irsync is developed at github.com/irsync-dev/irsync. Clone it and build the workspace:
git clone https://github.com/irsync-dev/irsync
cd irsync
cargo build --workspace
The workspace holds irsync itself and the tools that test it: fileset
(reference), filegen
(Generating test trees), irsync-stress
(Stress testing) and irsync-netstress
(Network stress).
Requirements
tools/dev-setup.sh sets most of this up and checks the rest. It installs
rustup, the toolchain with rustfmt and clippy, the musl target on Linux, the
Rust targets of every platform tools/ci.sh typecheck checks, the
nightly the fuzz targets build with, and cargo-nextest, cargo-deny,
cargo-fuzz, zizmor, dist, actionlint, shellcheck and mdbook. The nightly
is a large download, and only fuzzing and Miri need it. Those eight tools
are downloaded from their release pages and checked against SHA-256s kept
in the script. Cargo builds a tool only where its project has no binary for
your machine, or when the script’s hashes are for another version than
CI’s. There is no shellcheck binary for FreeBSD; there the script names the
package. They are held to the versions CI uses: if you have another
version, it is replaced. It points git at the repo’s hooks. System tools
such as rsync, Python and a C compiler it only checks, naming the package
to install. tools/dev-setup.sh --check reports without changing anything.
Run it again whenever you like.
It works on Linux, macOS and FreeBSD, and names the package for each one’s
package manager (apt, brew, pkg). It does not run on Windows; see
Windows.
- Rust.
rust-toolchain.tomlpins an exact Rust version, which rustup picks up; CI and releases use the same file. To move to a newer Rust, change the version there and run the full regression. - GNU rsync 3.1 or newer on
PATH, forcrates/irsync/tests/rsync_compare.rs, which compares irsync’s result with rsync’s. Without it the test prints a line and passes, whichcargo test -qhides, so it checks nothing. With theCIenvironment variable set, the test fails instead of skipping. On macOS the bundled rsync (2.6.9 or openrsync) is too old:brew install rsync. curl, and atarthat writes and reads.tar.xz, forcrates/irsync/tests/ssh_release.rs, which builds a small release tarball and downloads it from a local directory. GNU tar needs thexzprogram for that (sudo apt install xz-utils); macOS’s tar has xz built in.- pandoc and mandoc, for the man pages:
tools/build-man.sh OUTDIRbuilds them from the book with pandoc, and the tests intools/testscheck them with mandoc.tools/dev-setup.shchecks both and says how to install them. Thecheckjob fails without them. - groff, optional.
test_groff_renders_without_warningsrenders each page with it and skips without it. It runs on Linux CI. On a Mac,nix-shell -p groffis one way to get it. - minisign 0.10 or newer, optional. Maintainers sign releases with it
(The release signing key), and it makes the
signature test files. Older versions write a signature format that irsync
refuses. The
sign-release.shtests also run with the real minisign when it is there; with theCIenvironment variable set, they fail instead of skipping without it.
Windows
filegen, fileset and irsync-glob build and test on Windows, on x86_64
and ARM64. irsync and irsync-proto build there too, tests included (the
Unix-only tests are behind #[cfg(unix)]), but nothing runs their tests on
Windows yet, and irsync does not support Windows yet
(Known limitations). The other crates are not
built there, so cargo build --workspace is not the way. Name the three
crates:
cargo test -q -p filegen -p fileset -p irsync-glob --no-fail-fast
What you need:
- The MSVC Rust toolchain and the MSVC build tools. Only the
x86_64-pc-windows-msvcandaarch64-pc-windows-msvctargets are used, not the GNU toolchain and not 32-bit Windows. Install rustup, and Visual Studio Build Tools with the C++ tools and a Windows SDK. rustup picks up the version inrust-toolchain.toml. - Git Bash, which comes with Git for Windows, to run
tools/ci.sh. The repository’s.gitattributeskeeps the shell scripts with LF line endings in the working tree, which bash needs. - cargo-nextest, which
tools/ci.sh checkruns. Install it by hand (cargo install --locked cargo-nextest, or a release download).tools/dev-setup.shdoes not run on Windows.tools/ci.sh checkthere needs no Python, pandoc, mandoc or rsync. - Developer Mode, for the symlink tests. Making a symlink needs Developer
Mode, an elevated process or the symlink privilege. Without it, a test that
needs a symlink prints a line that starts
skipping:and passes. With theCIenvironment variable set, it fails instead, as the rsync comparison test does (Requirements).filegenfinds the same thing at the start of a run and leaves the symlink operations out (see On Windows). - A short checkout path and a short
CARGO_TARGET_DIR. The MSVC linker fails on a path over 260 characters. CI setsCARGO_TARGET_DIRtoC:\t. Clone somewhere likeC:\w\irsync. - Trees on an NTFS drive. The tests make their trees in the temporary directory, so that drive has to be NTFS too. ReFS, FAT, exFAT, network shares and the folders a virtual machine shares with its host are not supported.
The full regression, in Git Bash:
tools/ci.sh check
On Windows it runs cargo fmt --all --check, the fuzz lock check, one clippy
run, nextest and the doc tests for the three crates, and then a smoke run:
filegen fills and changes a tree, and fileset records it and checks it. A
bare tools/ci.sh runs check only, and prints that on Windows only check
runs, for those three crates.
Continuous integration
The workflow in .github/workflows/ci.yml runs on GitHub for every push to
main and every pull request, on Linux and macOS, and on Windows for the
three crates. The workflow installs
the tools; the checks themselves are in tools/ci.sh, one job there per job
in the workflow, so the same script runs them on your machine:
tools/ci.sh # every job
tools/ci.sh check # one job
tools/ci.sh --help
To change what CI checks, change tools/ci.sh.
The check job installs GNU rsync and runs, in this order:
cargo fmt --all --check
python3 -m unittest discover -s tools/tests # tests tools/dev-setup.sh and the man pages
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
cargo clippy --locked --workspace --all-targets --no-default-features -- -D warnings
cargo nextest run --locked --workspace --all-features --profile ci --run-ignored all
cargo test --locked --workspace --all-features --doc
--locked makes the run fail if Cargo.lock is out of date, as the release
build would.
The windows job runs tools/ci.sh check on windows-latest (x86_64) and
windows-11-arm (ARM64), in Git Bash, with CARGO_TARGET_DIR set to C:\t.
It covers filegen, fileset and irsync-glob, as above. It reports on
pull requests and pushes, but CI result does not need it, so a failure there
does not block a merge. A release run leaves it out.
The release-build job runs the release build itself for the two
Linux targets (x86_64 and arm64 musl): dist build, which runs
packaging/dist/build.sh, on the same runners as a release. It checks that release.yml is what
.github/scripts/release-yml.sh write makes, that each tarball holds the three man pages, and
that our installer, run on the tarball with a temporary home, installs a
working irsync and pages that man finds. A change that
would break a release fails here, before anyone tags it. On your machine it
builds the one musl target that matches it, on Linux only, and needs dist
and musl-gcc.
The freebsd-build job builds the FreeBSD tarball with the same build
script. It runs on FreeBSD x86_64 only, and CI does not run it. GitHub runs
it in a workflow you start by hand: see
Testing a version on FreeBSD.
The fuzz-build job builds the fuzz targets in fuzz/ with their pinned
nightly and runs each on its checked-in inputs. The long fuzz runs are in a
nightly workflow; see Fuzzing.
The miri job runs the tests that can run under Miri, which catches
undefined behaviour in unsafe code. It is slow, so it runs only when you
name it, and every night on GitHub; see
Static analysis.
The deny job checks the dependencies with cargo deny, for the platforms
irsync is built for and for both Windows targets, so it also checks the crates
only a Windows build uses. The deny-license-check job checks the licenses of
every platform’s dependencies; on GitHub its failure blocks a release, not
a pull request. The workflows job runs the workflow rule tests, actionlint
and zizmor, which needs PyYAML, actionlint and zizmor
(Supply chain,
Static analysis). The shell-scripts job runs shellcheck on every shell script, on every pull
request. A warning that is wrong for one line is turned off on that line,
with the reason in a comment.
Two things run only on GitHub: the macOS, Windows and arm64 runs, and the dependency review of a pull request.
The tests run with cargo-nextest, which runs each test
in its own process and tests from all files side by side. That makes the
run faster than cargo test, which runs one test file after another. The
ci profile in .config/nextest.toml runs every test even after a failure
and kills a test that runs longer than 5 minutes, naming it. --run-ignored all adds the slow network-fault tests that an everyday cargo test skips
(Testing). nextest does not run doc tests, so cargo test --doc runs those.
On macOS, CI uses the ci-macos profile instead. It leaves out a few slow
tests that work the same on every OS, which Linux CI still runs (see
Platform skips).
The second clippy run keeps the build without the otel feature compiling
(see Cargo features).
For everyday work you don’t need nextest: cargo test runs the same
tests. tools/ci.sh check needs it; tools/dev-setup.sh installs it.
The pre-push hook
.githooks/pre-push refuses a push whose commits are not rustfmt-clean, so a
formatting slip is caught before CI sees it. Every commit being pushed is
checked with cargo fmt --all -- --check in a throwaway worktree: what counts
is what the remote receives, not the state of the working tree. Install it
once per clone:
git config core.hooksPath .githooks
Before pushing
Clippy and the tests are not part of the hook. Run them yourself:
tools/ci.sh check
This is the full regression, the same script CI’s check job runs. After
a change under .github/, to the dependencies or to the release build, run
tools/ci.sh with no job, which runs CI’s other jobs too.
After a change to Rust code or its tests, also check that it still compiles on the other platforms:
tools/ci.sh typecheck
This runs clippy, with warnings as errors, for Linux (x86_64 and arm64
musl), macOS, FreeBSD and Windows, each on x86_64 and arm64. It needs no
compiler for those platforms: tools/typecheck-target.sh hands the C
build scripts a stand-in that writes empty files, since a check never
links. It finds code that does not compile there, such as a mistake behind
#[cfg(windows)], in a few minutes instead of a CI round. It runs
nothing, so CI still runs the tests. The list of platforms, and the crates
each one checks, is tools/typecheck-targets; on Windows that is
filegen, fileset and irsync-glob, the crates that build there.
tools/dev-setup.sh installs the Rust targets. A run of every job leaves
typecheck out.
Testing
This page is the start of the testing pages. For the case made to users, that a finished sync leaves the destination exactly like the source under the conditions stated there, and what backs it, see How we verify irsync’s correctness. This section is for people who change irsync and need to know which test to add or run.
The layers
There are four layers. They go from fast and narrow to slow and broad.
- Engine tests. Each runs a sender and a receiver inside one test
process and checks the result. They live in
crates/irsync/tests/and run withcargo test. With thetest-hooksfeature (see Cargo features) a test can inject a fault, slow a step or read the receiver’s event log. They catch logic bugs in one feature: the planner, the receiver, deletes, resume, filters. Reach for them first. A fix without one is not finished. - The loopback stress loop.
irsync-stresschanges a source tree with filegen, syncs it, and checks the copy withfileset check, over and over. It catches what no one thought to write a test for: odd mixes of files, renames, links, long names and big trees. It takes minutes. - netstress.
irsync-netstressruns the same loop through a simulated bad network: slow, lossy, and cut for up to a minute. It catches bugs in sessions, reconnect, resume and the transport. It takes many minutes and needs its own build. - Campaigns. Hunting bugs turns the stress loop into a search: many seeds, with the settings aimed at one part of irsync per row of a matrix. It catches the bugs a default run is too gentle to hit. It takes hours, so run it before a release or after a risky change, not on every push.
Which test for which change
| You changed | Add or run |
|---|---|
| The receiver, the planner, delta or chunk handling | An engine test in crates/irsync/tests/. Existing ones to extend: delta.rs, plan.rs, recv.rs, inplace.rs, content_equal.rs. See Receiving a changed file. |
| Deletes, filters or options | An engine test: delete.rs, filter.rs, filters_e2e.rs, push_options.rs. |
| Code that walks or writes the tree: scan, index, metadata, links, renames | An engine test, then a stress run in both directions: irsync-stress --direction push and --direction pull. |
| Sessions, reconnect, resume or the transport | An engine test (resume.rs), then a netstress run, for example --profile 4g-vehicle. |
| Anything risky, or something a default stress run barely touches (hard links, sparse files, odd timestamps, huge listings) | A row of the campaign matrix, run with crates/stress/tools/matrix.sh. |
A bug that stress or netstress finds should end as an engine test that fails before the fix and passes after it. The stress run found the bug; the engine test keeps it from coming back. CI runs the whole test suite on every push, which includes the engine tests and a short end-to-end test of each rig. The long stress, netstress and campaign runs are done by hand.
For everyday work, run the suite with the features CI uses:
cargo test -q --workspace --all-features --no-fail-fast
This skips five slow network-fault tests (marked #[ignore]) in
crates/netstress/tests/e2e.rs. They run the real fault binaries on real
time, take a few minutes together, and the first run also builds those
binaries. The full regression, which
CI and Before pushing use, runs them too:
tools/ci.sh check
With plain cargo test, -- --include-ignored adds them. No other test is
ignored, so it adds exactly these five.
On Windows, CI builds and tests only filegen, fileset and irsync-glob,
so name them:
cargo test -q -p filegen -p fileset -p irsync-glob --no-fail-fast
There, tools/ci.sh check in Git Bash is the full regression
(Windows). irsync and irsync-proto build on
Windows too, tests included (the Unix-only tests are behind #[cfg(unix)]),
but nothing runs those tests there yet.
The syncs through the fault layer in crates/irsync/tests/netsim.rs are
not ignored, though they need minutes of network time: they run client
and daemon in one process on tokio’s paused clock, over an in-memory
network (with_netsim in crates/irsync/tests/common). Whenever every
task waits on a timer, the clock jumps to the next one, so they finish in
about a second. Write a new test of irsync through the fault layer that
way. A test that runs the real fault binaries is ignored like the five.
That relies on everything with a deadline reading tokio’s clock
(tokio::time::Instant), not std::time::Instant. irsync’s reconnect,
--bwlimit and persistence timers do; telemetry and loops in blocking
threads keep the real clock, since paused time stands still there. iroh
up to 1.5.0 has QUIC read the real clock; the workspace Cargo.toml takes
iroh from the upstream commit with the fix
(n0-computer/iroh#4677)
until a release has it.
Before pushing lists the other checks.
Cargo features
otel(on by default) builds the OpenTelemetry export. The clippy run with--no-default-featureskeeps the build without it compiling.test-hooks(tests only; irsync’s dev-dependency on itself turns it on) adds the test fields ofSideHooks(crates/irsync/src/session/hooks.rs): injected faults, slowed steps, a cap on files in flight, and the receiver’s event log, whichcrates/irsync/tests/delta.rschecks the order of steps against (see Receiving a changed file below).netsimbuilds the fault layer thatirsync-netstressdrives. It needs its own build; see The fault build.
To check by hand that a build without otel ignores the telemetry
settings:
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 \
cargo run -p irsync --no-default-features -- -a src/ HOST:export/
stderr starts with irsync: built without OpenTelemetry support; ignoring [telemetry], and the sync runs as usual.
Platform skips
Tests that create non-UTF-8 file names skip when the filesystem refuses the
name (APFS does); on Linux they always run. See R29 in
IRSYNC_DECISIONS.md.
The rsync comparison test skips without GNU rsync 3.1 or newer, and fails
instead when CI is set (Requirements).
On Windows, a test that needs a symlink skips with a line that starts
skipping: when the user may not create symlinks, and fails instead when
CI is set, so CI cannot pass by skipping. Developer Mode, an elevated
process or the symlink privilege lets those tests run
(Windows). Tests of POSIX-only behaviour (chmod,
chown, FIFOs, devices, extended attributes) are compiled on Unix only. A
test that needs a file nobody can read holds it open with sharing denied.
The macOS CI job leaves out crates/irsync/tests/backpressure.rs,
crates/irsync/tests/blocking_pool.rs and crates/netstress/tests/e2e.rs,
through the ci-macos profile in .config/nextest.toml. The macOS runners
are slow and have 3 cores, and these tests take over a third of the test
time there, while the code they test works the same on every OS. Linux CI
runs them on every push, and a local run on a Mac runs them too. A test that
checks something macOS-specific belongs in none of these files.
Workload and stress tools
Three crates in the workspace exist to test irsync: filegen,
irsync-stress and irsync-netstress. They are described in the layers
above and on their own pages: filegen, Stress
testing and Network stress with netstress. None
of them links irsync; they drive it through its command line.
irsync-netstress reuses the stress crate’s library. filegen also makes
reproducible trees for benchmarks (Performance).
The end-to-end tests of stress and netstress run the real binaries.
cargo test -p stress does not build the other binaries it needs: run
cargo build --workspace first, or use cargo test --workspace. The
netstress end-to-end tests run only with -- --include-ignored; they
build the fault binaries into target/netsim/debug themselves the first
time, which takes a few minutes.
Fuzzing
Fuzzing feeds a function millions of made-up inputs and watches for a crash. The fuzzer, libFuzzer, keeps each input that reaches code no input before it reached, and builds new inputs from those. The kept inputs are the corpus.
What is fuzzed is the code that reads bytes from a peer or from another
program. There is one target (a small program around one entry point)
per file in fuzz/fuzz_targets/:
| Target | What it reads | Checks beyond “no crash” |
|---|---|---|
frame | a stream of frames, through read_body, each decoded as every message type irsync reads off the wire | a decoded message encodes and decodes to the same value |
delta | an old file and a DataChunk, rebuilt with delta::decode | decode(encode(new, basis), basis) == new |
glob | a pattern and a path, split at a NUL byte, through Glob::new and matches | the match ends |
manifest | a file opened as .fileset.sqlite the way fileset list opens it, then every entry | none |
redb_manifest | a file opened as .fileset.redb the same way, then every entry | none |
pbwalk | bytes as a capture file, listed with pbwalk --full, unwrapped and as-is | none |
relpath | bytes given to RelPath::new | an accepted path is not absolute and has no empty, . or .. component and no NUL |
A target fails on a panic, a crash, an input that takes over 10 seconds or memory over 2 GiB.
fuzz/ is a project of its own, outside the workspace. cargo-fuzz needs a
nightly Rust, so it builds with the nightly named in
fuzz/rust-toolchain.toml; everything else stays on the stable version.
tools/dev-setup.sh installs that nightly and cargo-fuzz. fuzz/ has its
own Cargo.lock. cargo deny does not check it, because those crates are
only built for fuzzing and never shipped.
fuzz/Cargo.lock follows the main Cargo.lock, so that the fuzzed code is
built with the same dependencies as the released code. After any change to
Cargo.lock, run:
tools/sync-fuzz-lock.sh
and commit both files. It writes fuzz/Cargo.lock again from a copy of
Cargo.lock. tools/ci.sh check runs tools/sync-fuzz-lock.sh --check,
which fails if the two files have a crate at different versions, or if
fuzz/Cargo.lock is out of date. Neither needs the nightly.
To build every target and run each on its seeds, the inputs checked in
under fuzz/seeds/<target>/:
tools/ci.sh fuzz-build
CI runs this on every pull request that changes code. The first build takes a few minutes. To fuzz each target for five minutes:
FUZZ_SECONDS=300 tools/ci.sh fuzz
Without FUZZ_SECONDS it is one minute each. The corpus grows in
fuzz/corpus/<target>/, which git ignores, and the next run starts from
it. The nightly workflow (.github/workflows/nightly.yml) does the same
for ten minutes per target, every night, and keeps the corpus in the
Actions cache.
To run one target by hand until you stop it with Ctrl-C:
nightly=$(sed -n 's/^channel = "\(.*\)"/\1/p' fuzz/rust-toolchain.toml)
host=$(rustup run "$nightly" rustc -vV | sed -n 's/^host: //p')
cargo +$nightly fuzz run --target "$host" relpath \
fuzz/corpus/relpath fuzz/seeds/relpath
host is your machine’s target, as tools/ci.sh finds it; this works on
Linux and on a Mac. Always pass it. Without it, the cargo-fuzz that
tools/dev-setup.sh downloads on Linux builds for musl, which the
address checks libFuzzer builds in do not support.
Adding a target
- Write
fuzz/fuzz_targets/NAME.rsaround one public function, and add a[[bin]]for it tofuzz/Cargo.toml. If the function is private, add a small#[doc(hidden)] pubentry point rather than copying the code. - Put at least three real inputs in
fuzz/seeds/NAME/: bytes the code reads in normal use, such as a real encoded message. Fuzzing then starts deep in the code, not at its first check. - Run it for a minute. libFuzzer’s
cov:number (how much code the inputs reach) must rise above its value on theINITEDline, which is what the seeds alone reach. If it does not, the target misses the code.
tools/ci.sh finds every file in fuzz/fuzz_targets/.
When a target fails
libFuzzer writes the failing input to fuzz/artifacts/<target>/. A failed
nightly run uploads that directory as the fuzz-artifacts artifact of the
run. To run the input again, with nightly and host set as above:
cargo +$nightly fuzz run --target "$host" relpath \
fuzz/artifacts/relpath/crash-...
A crash in the nightly run is public. The repository is public, so anyone can read the run’s log and download its artifact. The log shows the input too: libFuzzer prints a short input in hex and Base64, with the panic message and the stack trace.
So first decide whether someone could exploit it: memory unsafety, a write outside the destination tree, or a small input from a peer that makes irsync use memory or CPU without bound. If it looks exploitable:
- Download the artifact, then delete the whole run, not just the
artifact:
gh run delete <run id>. - Tell the maintainer privately, as SECURITY.md says.
- Do not open a public issue. Keep the input and any description of it out of issues, pull requests and commits.
Otherwise fix it like any bug, with a test in the crate’s own tests that
fails before the fix. Add the input to fuzz/seeds/<target>/ too:
fuzz-build then keeps it fixed.
Static analysis
Three tools read the code and the workflows for security bugs, and two lints guard unsafe code: one in the compiler, one in clippy.
Unsafe code. Rust code marked unsafe can do what the compiler cannot
check, such as call the operating system. Two workspace lints (in the root
Cargo.toml) guard it. The compiler’s unsafe_op_in_unsafe_fn asks for an
unsafe block around each unsafe call, also inside an unsafe fn.
Clippy’s undocumented_unsafe_blocks refuses an unsafe block without a
// SAFETY: comment above it. The comment says why that call is sound: which rule
holds, and what in the code keeps it. The crates with no unsafe code,
irsync-glob, irsync-proto and netstress, forbid it. tools/ci.sh check runs clippy. The Windows code of fileset and filegen has three
such blocks, all calls into Win32 that no wrapper crate makes: one in
fileset (GetFileInformationByHandleEx, for the change time and a reparse
point’s tag) and two in filegen (the same call for the tag, and
DeviceIoControl for sparse files and zeroing a range). They are in
platform/windows.rs of each crate. irsync’s Windows code keeps all of
its unsafe blocks in platform/windows/native.rs, one small function per
native call. Miri cannot check them, so their tests cover them; irsync’s
do not run on Windows yet.
zizmor looks for security problems in the GitHub workflows, such as a
token left on disk after a checkout or a workflow with more permissions
than it needs. It runs in the workflows job, next to actionlint:
tools/ci.sh workflows
tools/dev-setup.sh installs it. Fix what it finds. If a finding is wrong
for us, ignore it in .github/zizmor.yml, with the reason on the same
line. Findings in release.yml are ignored there, because dist writes
that file.
CodeQL, GitHub’s code analysis, reads the Rust code and the workflows
(.github/workflows/codeql.yml). It runs on every pull request, on every
push to main and once a week. It does not run on your machine. Its
findings show under the repository’s Security tab, in Code
scanning, and on the changed lines of a pull request. It is not part of
CI result yet.
Miri runs tests in an interpreter that stops at undefined behaviour:
memory use the language does not allow, such as reading past the end of a
buffer. A normal test run can pass right over it. Miri is about a hundred
times slower, and it cannot make most system calls. So it runs only the
tests that need none: irsync-glob, irsync-proto, the delta codec
tests (crates/irsync/tests/sub_chunk.rs), and the parts of fileset
that compare, escape and match names and that convert Windows names. The list, and what is left out
and why, is miri_packages in tools/ci.sh. It uses the nightly from
fuzz/rust-toolchain.toml, which tools/dev-setup.sh installs with
Miri:
tools/ci.sh miri
It takes a few minutes, so it is not in a run of every job. The nightly
workflow runs it every night. A test that is too slow under Miri, or
makes a system call, is marked
#[cfg_attr(miri, ignore = "reason")].
Receiving a changed file
The properties described in
Receiving a changed file are
pinned by end-to-end syncs between two engines in crates/irsync/tests/. They
read the receiver’s event log (SideHooks::event, behind the test-hooks
feature), which records prehash, plan, chunklist, need, chunk (a
network chunk written), copied (the local copy task finished), basis,
ops (a chunk verified from operations), identical, clone, inplace and
append, each with the path. delta.rs checks the order of the steps (the
request leaves before the local copies, which a 150 ms delay per copy makes
visible), a stale local chunk that is re-requested, and that the old file is
hashed once from plan time; sub_chunk.rs tests the block codec in
irsync::delta on its own; sub_chunk_delta.rs measures the bytes of the
sub-chunk delta and its fallbacks; inplace.rs covers the cloned .part,
--inplace and --append (the clone tests skip, and say so, where target/
is on a filesystem that cannot clone); content_equal.rs covers settling in
place and -c; warm.rs covers same-size candidates and irsync index;
recv.rs holds the writer-level tests; plan.rs pins the planner’s
--append and --append-verify decisions.
To find the code for a step: the early hash is the Delta arm of
session/receiver/planner.rs; opening, comparing, partitioning and choosing bases are
in session/receiver/file_io.rs (open_writer, unchanged_file, local_sources,
basis_specs, offer_bases, rebuild, copy_local_chunks, finish_unit,
settle_identical, finalize, the in-place Gate); dispatch and re-requests
are in session/receiver/mod.rs (on_opened, on_drained, MAX_REREQUESTS);
the sender’s use of a basis is session/sender/mod.rs (on_basis) and
data_stream.rs (payload); the codec is delta.rs; the writer, cloning and
adoption are part_file.rs (FileWriter, reflink); the folded whole-file hash
is tree_hash.rs; chunk lists in parts are session/parts.rs; the test hooks
are the fields of SideHooks in session/hooks.rs.
Generating test trees with filegen
Part of Testing: the tool that changes the tree in every stress loop.
filegen simulates the use of a POSIX filesystem, and, with fewer operations,
of an NTFS one (see On Windows). It walks a Markov chain of
filesystem operations (create, append, truncate, rename, symlink, hard link,
chmod, set mtime, punch a hole, remove a subtree, and more) and applies each
one somewhere in a directory tree. Every decision, the bytes written
included, comes from a seeded generator, so a run is reproducible from its
seed and can be resumed from its saved state as if it had never stopped. It
shares no code with irsync or fileset.
It is the mutating half of the stress loop: filegen run mutates a source
tree, fileset update records it in the tree’s manifest, irsync carries
tree and manifest to another host, and fileset check there confirms that
every change arrived. irsync-stress runs that loop. filegen
only mutates, logs and records. Every step is timed, so a run is also a
performance trace of the filesystem under test.
How the chain, targets, sizes and resume work, and how to extend it, is on How filegen works.
The design is in 2026-10-20-filegen-design.md, the calls made while building it in FILEGEN_DECISIONS.md.
Generate a tree
Build it with cargo build -p filegen (or --release); the binary is
target/debug/filegen. The tree must be an existing directory, empty or
populated. Keep the output directory outside it:
mkdir -p ~/src-tree
filegen run --seed 42 --steps 1000 --out-dir /tmp/fg ~/src-tree
This writes /tmp/fg/filegen-42.log and /tmp/fg/filegen-42.state.yaml.
Continue the same history later, from its state file:
filegen run --resume /tmp/fg/filegen-42.state.yaml --steps 1000 ~/src-tree
Bound the tree’s size and change any configuration key on the command line:
filegen run --seed 7 --steps 1000 --max-total-size 1G --max-file-size 16M \
--set content.pattern_fraction=0.2 --out-dir /tmp/fg ~/src-tree
Draw and log the steps without touching the tree:
filegen run --seed 42 --steps 1000 --dry-run --out-dir /tmp/fg ~/src-tree
To see every configuration key with its default, make a one-step dry run and
read the config: block of its state file, as in
Configuration.
Reference
Command
filegen run [OPTIONS] --steps <N> (--seed <S> | --resume <STATEFILE>) <PATH>
<PATH> must be an existing directory, empty or populated.
--steps <N>: operations to perform in this invocation (required)--seed <S>: start a fresh run from this 64-bit seed--resume <STATEFILE>: continue from a previous run’s state file; exactly one of--seedand--resumeis required--config <FILE>: YAML configuration file; every key is optional--out-dir <DIR>: where the log and state file go (see below)--prefix <PREFIX>: base name of the output files instead offilegen-<seed>; must not be empty,.,.., or contain/(on Windows, nor\)--set <KEY=VALUE>: set any configuration key by its dotted path, value parsed as YAML (repeatable), e.g.--set content.pattern_fraction=0.2--pace <PACE>: when each step starts.fast(the default) never waits;steady:<N>starts at most N steps a second;bursts:<ON_MS>:<OFF_MS>runs flat out for ON_MS milliseconds, then waits OFF_MS, and repeats. Pace only decides when a step starts, never which one, so it does not change the tree a seed makes. irsync-stress uses it for--concurrent.--dry-run: draw and log every step, update the model, but touch nothing--force: with--seed, truncate an existing log and state file for this prefix instead of refusing-q, --quiet: no progress line and no file paths on stderr-v, --verbose: echo every log line to stderr (hides the progress line)--max-total-size <SIZE>,--max-file-size <SIZE>,--max-depth <N>,--max-path-len <N>,--remove-tree-max-entries <N>,--checkpoint-steps <N>,--fsync <true|false>: the top-level configuration keys of the same name.--fsynctakes a value.
Sizes are plain bytes or carry a K, M, G or T suffix (powers of
1024). Precedence, lowest first: built-in defaults, the resumed state’s
config (without out_dir and prefix, see below), the --config file,
--set, the dedicated flags. Unknown keys
are an error, max_file_size may not exceed max_total_size, the
names.classes weights may not all be 0, and no names.extensions entry
may contain / or NUL.
Output files
The output directory is, first that is set: --out-dir, the out_dir
config key, $FILEGENTMP, $TMPDIR, /tmp. A relative directory is
resolved against the current directory, and the state file records the
absolute directory used. A --resume ignores the out_dir and prefix
saved in its state file: unless --out-dir, --prefix, --set or a
--config file given on that invocation says otherwise, it writes to the
directory of the state file under the prefix taken from the state file’s
name, whatever the current directory or the environment. So a resumed run
keeps appending to the same history: the log is appended to across
resumes, each invocation adding its own # run header. Both paths are
printed to stderr at the start unless -q. With the default prefix and
seed 42:
| real run | --dry-run | |
|---|---|---|
| log | filegen-42.log | filegen-42.dry.log |
| state | filegen-42.state.yaml | filegen-42.dry.state.yaml |
filegen refuses to start (exit 2) when:
- the output directory is, or lies inside,
<PATH>(after resolving symlinks); - a
--seedrun finds either output file already present; the message names the ways out:--resumeto continue that history,--prefixto start a separate one,--forceto truncate both. With--forcethe files are truncated only after the initial walk of the tree succeeded; - a dry-run state file is resumed without
--dry-run, or a real one with it; - the state file’s
format_versionis not 3 or 4 (a version 1 file comes from an older content generator, whose bytes the same seed no longer reproduces; a version 2 file from rand 0.8, whose sampling made different choices from the same seed); - a
--resumestate file that was written on the other platform family, or with other capabilities than this machine has (see On Windows); - the canonical root length plus
max_path_lenreachesPATH_MAX.
Log
One line per step, key=value pairs in a fixed order:
step=<n> ts=<RFC 3339, µs, UTC> op=<kind> path="<rel>" [to="<rel>"] [dry=1] [bytes=<n>] [<detail>=<v> ...] [post=<stat>] [post_to=<stat>] [pressure=<0.xx>] dur_us=<n> [gen_us=<n>]
The # run header line ends in platform=<unix|windows> and
caps=<list>: the system that made the run and the capabilities found there,
symlinks and sparse joined with ,, or - for none. On Unix it ends in
platform=unix caps=symlinks,sparse.
step counts across resumes. Paths are relative to the root, quoted and
escaped (\", \\, and \xhh for control bytes and invalid UTF-8) so any
name round-trips. bytes is the data written, when non-zero. Details
include size, content (random, zeros, repeat_byte,
repeat_block), offset/len, mode, mtime/class, target,
target_kind, absolute, entries and emulated=1 (a hole written as
zeros). pressure appears while the total-size reweighting is in effect.
post is the stat of path right after the step, as
kind:size:mode_octal:mtime_ns: f file, d directory, l symlink,
p fifo, c or b device (and s for a socket); the size in bytes, the
mode bits in octal (0 on Windows), the modification time in nanoseconds since
the epoch. It is - when the path is absent after the step (a delete or a
rename away). post_to is the same for to, and appears only for steps
that have a to. Neither appears in a dry run, which touches nothing.
The stress harness reads them to rebuild what the source held.
dur_us times the filesystem syscalls only (including fsync if enabled),
not the choice of operation. An operation that writes drawn content
(create_file, append, overwrite_range, rewrite) generates the bytes
in 1 MiB chunks between its writes; that time is taken out of dur_us and
reported as gen_us, so dur_us measures the filesystem whatever the
generator costs. A failed step is logged as
step=<n> ts=... op=<kind> path="<rel>" [to="<rel>"] error="<os error>",
naming the path the failing call acted on (for a create, the new entry;
to for a rename or hard link).
From a real run (paths shortened; post is f:44002:664:..., a 44002-byte
file with mode 0664 whose mtime is 2026-10-20T14:24:51.571Z):
# run seed=42 start_step=0 steps=1000 log="/tmp/fg/filegen-42.log" state="/tmp/fg/filegen-42.state.yaml" config="-" dry_run=0 started=2026-10-20T14:24:51.569059Z platform=unix caps=symlinks,sparse
step=6 ts=2026-10-20T14:24:51.571654Z op=append path="2yg5uow38.jpg/f4rx i3iipl66u7pmc1e.bin" bytes=30165 size=44002 content=random post=f:44002:664:1792506291571000000 dur_us=1208 gen_us=12
...
# end steps_done=1000 outcome=ok elapsed_ms=7638
# stat op=create_file count=219 bytes=117340131 p50_us=109 p99_us=156217 max_us=156975 gen_total_us=48112
# stat op=append count=183 bytes=74836731 p50_us=27 p99_us=156299 max_us=156307 gen_total_us=30577
The # end line is followed by one # stat line per kind seen in this
invocation; the percentiles are over dur_us, and kinds that write drawn
content add gen_total_us, the sum of their gen_us. outcome is ok, "failed: <message>" or
"interrupted: SIGINT" / "interrupted: SIGTERM" (on Windows always
"interrupted: Ctrl-C"). A dry run marks each
step line dry=1 and logs dur_us=0 (and gen_us=0 where the kind
reports it).
A step whose drawn kinds all lack a target, and where even the fallback,
create_file in the root, finds no name that fits (for example with a tiny
max_path_len), does nothing: it logs no step line and does not advance
steps_done, but counts toward --steps. The # end line then ends in
skipped=<n>, the outcome stays ok, and unless -q one warning on stderr
says how many steps were skipped.
State file
A YAML document, written to a temporary file and renamed into place:
format_version: 4. A version 3 state is still read, as a Unix state with every capability.seed: the seed the history started fromsteps_done: steps completed over all runs of this historyrng: the ChaCha8 chain generator state (seed,stream,word_pos); file bytes come from Xoshiro256++ seeded by a draw from it, so they need no state of their ownchain_state:last_kind(the previous operation) andanchor(the escaped relative path of the directory it touched;''is the root)dry_run: whether a dry run wrote itplatformandcaps: the system the history started on,unixorwindows, and the capabilities found there (symlinksandsparse, each true or false). A resume must find the same.config: the effective configuration, fully expanded, without_dirthe absolute output directory used; usable as--configtree:entriesandtotal_bytesas filegen last knew them (advisory)last_run:started,finished,steps(this invocation),outcome(as in the log, orrunningfor a checkpoint), andsummary, the per-kind statistics of the# statlines
Resume, interrupts and checkpoints
On --resume filegen does not trust the state file’s picture of the tree:
it walks the tree afresh and rebuilds its model, then continues from the
saved generator state. If the tree is as the previous run left it, the
result is identical to an uninterrupted run (same tree, same step lines).
If the tree was altered in between, the run continues deterministically from
the altered tree, reproducible but no longer identical; compare tree in
the state file with the tree to notice.
SIGINT and SIGTERM let the step in flight finish, then write the log footer and the state file and exit 130 or 143; the state is resumable. A second SIGINT during that shutdown exits 130 at once without writing. Signals are handled from the end of the initial walk on.
Every checkpoint_steps steps (default 1000) the state file is rewritten
with outcome running and the log is flushed, so a kill no handler can
catch loses at most that many steps of generator position. The tree, and
possibly the log, are then ahead of the checkpoint: a resume starts again at
the checkpoint’s step (its # run line shows start_step), so the log can
hold a few step numbers twice, and the tree is in the “altered” case above.
Exit codes
0: all steps done1: an operation failed (the failure line, footer and state are written, with the generator rewound to before that step), or another I/O error2: usage, configuration or state-file error, or a refusal above; a--resumestate file that is missing, unreadable or invalid is reported asstate file <path>: <error>130/143: interrupted by SIGINT / SIGTERM (128 + signal number). On Windows the interrupt is always 130.
Safety
filegen never writes outside the root: every target comes from its model of
the tree, and the output directory may not lie inside it. Some entries are
off limits: never targets, never descended into, and a directory holding
one is never removed or renamed. They are entries named .fileset* at any
depth, entries on another filesystem (mount points), sockets and other
unknown file types, and entries the start-up walk cannot stat. Unless
filegen runs as root, they are also:
- any directory it cannot list;
- any entry not owned by its effective uid;
- any regular file without owner read and write (
mode & 0o600 != 0o600, such as the0444files of a git checkout); - any directory without owner read, write and search
(
mode & 0o700 != 0o700).
As root these four do not apply, and a directory that cannot be listed
(because it vanished during the walk) is kept as an empty directory.
filegen’s own chmod always keeps owner read and write (and search on
directories), so, with a umask that keeps the owner’s bits (any usual one),
nothing filegen creates ever becomes off limits. Absolute
symlink targets may point outside the root, but filegen only creates the
link.
On Windows
filegen builds and runs on Windows, on x86_64 and ARM64, with the tree on
NTFS. cargo build -p filegen makes target\debug\filegen.exe. irsync does
not run on Windows yet, so neither irsync-stress nor irsync-netstress does.
The default output directory is /tmp on every system, which on Windows is
\tmp on the current drive. Give --out-dir, or set FILEGENTMP.
Operations.
| Group | Operations | On Windows |
|---|---|---|
| Content | create_file, append, truncate, overwrite_range, rewrite | yes |
| Sparse | punch_hole | yes, if the volume takes sparse files |
| Tree | mkdir, rmdir, remove_tree, delete_file, rename | yes |
| Replace | rename_over | regular files only |
| Links | hardlink | yes, up to 1023 links to a file |
| Symlinks | symlink, repoint_symlink, delete_symlink | if this user may create symlinks |
| Time | set_mtime | yes, in steps of 100 ns |
| POSIX only | mkfifo, chmod, set_xattr, chown, mknod | never |
rename_over takes regular files only, on every system. On Windows a rename
cannot replace a directory, and filegen never asks it to.
Capabilities. Two things depend on the machine and the volume, not only on
the system. At the start of a run filegen finds them by trying, with a
file named .filegen-probe-<pid> that it removes again:
symlinks: this user may create a symlink. That needs Developer Mode, an elevated process or the symlink privilege.sparse: the volume takes sparse files.
If the probe file is there already, left by a run that was killed, the run stops with an error that names it. It can be deleted.
A real run tries in the tree. A dry run touches nothing in the tree, so it tries in the output directory. If the two are on different volumes, a dry run may not predict the real run. On Unix every capability is taken to be there and nothing is tried.
What is turned off. An operation that cannot run here gets weight 0 and
the run says so once, on stderr unless -q:
filegen: not available here, weight set to 0: mkfifo, chmod, set_xattr, chown, mknod
The always-disabled kinds on Windows are mkfifo, chmod, set_xattr,
chown and mknod. Without the symlink capability symlink,
repoint_symlink and delete_symlink join them, and without sparse support
punch_hole. So one YAML config runs on both systems. If zeroing these kinds
leaves a row of the weight table with nothing to draw, the configuration is
refused and the message says so.
Reproducibility holds per platform family and capability set. The same
seed gives the same run on any Windows machine that has the same
capabilities, and a different run from Unix. The log’s # run line and the
state file record both, and a --resume refuses a state written on the other
family or with other capabilities, because the run would no longer be the one
the seed gave. A state file of version 3 is read as a Unix state with every
capability, so a run in progress resumes as before.
Names. filegen never makes a name NTFS forbids (<, >, :, ", |,
?, *, \ and the code points below U+0020). It counts a name’s length
in 16-bit units, 255 at most (names.max_len), and a path’s at most 32,767.
No two names in a directory differ only by case or normalisation. The
awkward class makes a trailing dot or space on both systems. On Windows
names.edge_rate (default 0.02) is the share of names that are further edge
cases NTFS allows: a word with one unpaired surrogate in it, or a reserved
device name (CON, PRN, AUX, NUL, COM1, LPT1), with an extension
half the time. Unix ignores the key, and a seed’s names there do not change.
The log writes the bytes of an unpaired surrogate as \xhh, like a name that
is not UTF-8 on Unix.
Symlinks. Windows has file symlinks and directory symlinks. filegen
makes the kind that matches the target, and a file symlink for a dangling
target. A relative target is written with \. An absolute target is written
in the form read_link returns: the \\?\ prefix is left off when the path
is short and means the same without it. That way the bytes written, logged and
read back agree. For a device name that form depends on the Windows build.
Off limits. Entries on another volume, junctions and other reparse
points that are not symlinks, and entries the start-up walk cannot stat are
off limits, as on Unix. So is any entry with the read-only attribute: a change
to it would fail again on every resume. filegen never sets that attribute.
There is no owner check and no mode check, and the mode in a post= stat is 0.
Files another program holds. Antivirus, the search indexer or any other
program that holds a file open without sharing it makes a step on that file
fail with a sharing violation (os error 32). The run stops as on any failed
step: the log gets the step’s error= line, the footer and the state are
written, and filegen exits with status 1. Once the file is free, --resume
goes on from the last step that was done.
Interrupts. On Windows the first console event lets the step in flight
finish, writes the log footer and the state, and exits with 130. A second
event exits at once, without writing. The handler comes from the ctrlc
crate, which is told about every console event and not which one it is. So
the log always says Ctrl-C, and the exit status is 130 for each.
Windows treats the events differently once the handler returns:
- For Ctrl-C and Ctrl-Break the process carries on, so the step finishes and the state is saved.
- For closing the console window, logoff and shutdown, Windows ends the process
shortly after the handler returns. A saved state is not guaranteed there.
The checkpoints (every
checkpoint_stepssteps) are what a resume then starts from.
There is no polite stop from another process yet: nothing like SIGTERM asks a
filegen in the background to finish its step and save.
unsafe. The Windows code has two unsafe blocks, each with its
// SAFETY: comment: GetFileInformationByHandleEx reads a reparse point’s
tag, and DeviceIoControl marks a file sparse and zeroes a range. punch_hole
is crate-private, because the second block is sound only for the files the crate
opens itself.
Configuration
The state file always carries the effective configuration with every
default filled in, so the way to see the schema is a one-step dry run (for
example filegen run --seed 1 --steps 1 --dry-run --out-dir /tmp/x <DIR>)
and the config: block of /tmp/x/filegen-1.dry.state.yaml. The defaults
from such a run, with comments added, nested values in YAML flow style, and
out_dir put back to its default null (a state file records the directory
used); it loads as --config and yields the default configuration:
out_dir: null
prefix: null
max_total_size: 25G
max_file_size: 256M
max_depth: 32
max_path_len: 900
remove_tree_max_entries: 1000
fsync: false
checkpoint_steps: 1000
# A new file is empty with weight `empty`, else log-uniform within a band:
# small from 1 byte, medium from small.max, large from medium.max to max_file_size.
size_distribution:
empty: 0.05
small: {weight: 0.65, max: 64K}
medium: {weight: 0.25, max: 8M}
large_weight: 0.05
# This fraction of writes uses one of `patterns` instead of random bytes.
content:
pattern_fraction: 0.05
patterns: [zeros, repeat_byte, repeat_block]
block_size: 4K
# Relative weights of the name styles. Names are unique per directory under
# case folding and NFC normalisation, on every platform.
names:
classes: {plain: 70.0, spaces: 8.0, dotfile: 5.0, unicode: 8.0, long: 3.0, awkward: 6.0}
extensions: [txt, bin, jpg, log, dat, md, json, '']
max_len: 255
# The share of names that are edge cases: on Windows only, ignored on Unix.
edge_rate: 0.02
# file/dir/dangling weight the target kind; absolute is a probability.
symlink: {file: 0.5, dir: 0.2, dangling: 0.3, absolute: 0.2}
# Modes are quoted octal strings. special_weight is the chance of adding one
# of suid, sgid, sticky. Owner rw (rwx on directories) is always kept.
chmod:
modes: ['0644', '0600', '0755', '0700', '0664', '0775', '0444', '0555']
special_weight: 0.05
# Class weights. Times are drawn relative to 2026-10-20T00:00Z, not the clock.
mtime: {recent: 0.6, distant: 0.3, future: 0.1, distant_years: 40, future_years: 5}
# Where a target is drawn from: below the directory the previous step
# touched, below its parent, or anywhere.
locality: {same_dir: 0.6, parent: 0.2, anywhere: 0.2}
# Previous kind -> next kind. A kind that is 0 in every row never occurs.
weights:
create_file: {create_file: 15, append: 30, truncate: 3, overwrite_range: 20, rewrite: 3, punch_hole: 0.7, delete_file: 2, mkdir: 3, rmdir: 1, remove_tree: 0.5, rename: 3, rename_over: 1, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
append: {create_file: 25, append: 20, truncate: 4, overwrite_range: 15, rewrite: 3, punch_hole: 1, delete_file: 4, mkdir: 5, rmdir: 3, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
truncate: {create_file: 20, append: 20, truncate: 2, overwrite_range: 15, rewrite: 5, punch_hole: 1, delete_file: 4, mkdir: 4, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
overwrite_range: {create_file: 20, append: 20, truncate: 4, overwrite_range: 15, rewrite: 3, punch_hole: 1, delete_file: 4, mkdir: 4, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
rewrite: {create_file: 20, append: 18, truncate: 4, overwrite_range: 15, rewrite: 3, punch_hole: 1, delete_file: 4, mkdir: 4, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
punch_hole: {create_file: 20, append: 18, truncate: 4, overwrite_range: 15, rewrite: 3, punch_hole: 1, delete_file: 4, mkdir: 4, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 1, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
delete_file: {create_file: 25, append: 12, truncate: 2, overwrite_range: 10, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 6, rmdir: 3, remove_tree: 2, rename: 4, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
mkdir: {create_file: 45, append: 2, truncate: 1, overwrite_range: 2, rewrite: 1, punch_hole: 0.5, delete_file: 1, mkdir: 20, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 1, symlink: 3, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.5, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
rmdir: {create_file: 20, append: 8, truncate: 2, overwrite_range: 6, rewrite: 2, punch_hole: 0.5, delete_file: 4, mkdir: 12, rmdir: 4, remove_tree: 3, rename: 4, rename_over: 2, symlink: 3, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.5, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
remove_tree: {create_file: 20, append: 8, truncate: 2, overwrite_range: 6, rewrite: 2, punch_hole: 0.5, delete_file: 4, mkdir: 12, rmdir: 3, remove_tree: 3, rename: 4, rename_over: 2, symlink: 3, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.5, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
rename: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
rename_over: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
symlink: {create_file: 15, append: 10, truncate: 2, overwrite_range: 8, rewrite: 2, punch_hole: 0.5, delete_file: 3, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 6, repoint_symlink: 5, delete_symlink: 4, hardlink: 0.5, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
repoint_symlink: {create_file: 15, append: 10, truncate: 2, overwrite_range: 8, rewrite: 2, punch_hole: 0.5, delete_file: 3, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 6, repoint_symlink: 5, delete_symlink: 4, hardlink: 0.5, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
delete_symlink: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
hardlink: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
mkfifo: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
chmod: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
set_mtime: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
set_xattr: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
chown: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
mknod: {create_file: 20, append: 15, truncate: 4, overwrite_range: 12, rewrite: 3, punch_hole: 0.7, delete_file: 6, mkdir: 5, rmdir: 2, remove_tree: 1, rename: 3, rename_over: 2, symlink: 2, repoint_symlink: 1, delete_symlink: 1, hardlink: 0.7, mkfifo: 0.5, chmod: 3, set_mtime: 3, set_xattr: 0, chown: 0, mknod: 0}
xattr:
names: [user.filegen.a, user.filegen.b, user.filegen.c, user.filegen.d]
max_value: '256'
chown: {uids: [], gids: []}
mknod: {char_fraction: 0.5}
set_xattr, chown (which also needs ids in chown.uids or chown.gids,
and the privilege to give files away) and mknod (skipped unless root) are
off by default through zero columns in weights. Above 80% of
max_total_size a pressure rises linearly from 0 to 1 at the cap, damping
the kinds that grow the tree and boosting those that shrink it; the log
shows it as pressure=.
How filegen works
Part of Testing: how the filegen tool chooses what to do.
This page explains how filegen decides what to do to a tree: the chain that picks the next operation, how it picks a target, how big things are and what they are called, and how a run is reproduced and resumed. It also says where to change filegen when it needs to do more. For how to run it and every option, see Generating test trees with filegen.
Why a Markov chain
Real use of a filesystem comes in patterns. A file is created and then appended to. A directory is made and then filled. A file is written and then renamed. Sync bugs tend to hide in exactly these situations.
Independent random operations rarely build them. A chain does. In a Markov chain, the next operation depends on the one before it. So filegen can make “create, then append” likely, and still be exactly repeatable from a seed.
How it works
The table
Every operation is an OpKind (in crates/filegen/src/kind.rs). There are
22 of them. The chain (crates/filegen/src/chain.rs) is a 22 by 22 table
of weights. Each row is the previous kind. Each column is the next kind. To
pick the next operation, filegen takes the row of the operation it just did
and draws a column, with probability in proportion to the weights.
The first step starts from mkdir, so a fresh run opens as if a directory
had just been made.
The defaults are in DEFAULT_TABLE in crates/filegen/src/config.rs. The
full block is in the
Configuration section of the filegen page, and
is not repeated here.
Switching a kind off
A kind is off when its column is 0 in every row. It can then never be
drawn. set_xattr, chown and mknod are off by default this way,
because they need privileges or filesystem support. Turning one on means
giving its column a weight, as in Tuning without code.
A row may not be all zeros, and no weight may be negative. filegen refuses to start with such a table.
A run can also switch kinds off by itself: the ones the system or the machine cannot do. See Platforms.
Locality
Real use also stays in one place. filegen remembers the directory the last
operation touched, called the anchor. The next target is chosen near it
(crates/filegen/src/pick.rs):
- with probability
locality.same_dir(0.6), from below the anchor, - with probability
locality.parent(0.2), from below its parent, - otherwise (0.2,
locality.anywhere), from anywhere in the tree.
If the chosen scope holds nothing suitable, the search widens. If no
target exists at all for the drawn kind (a rmdir in a tree with no
directories, say), filegen draws another kind, up to 16 times. After that
it creates a file in the root. Only if even that fails is the step skipped.
Size pressure
filegen keeps the tree under max_total_size. Below 80% of that cap
nothing changes. Above it, a pressure rises in a straight line from 0 to 1
at the cap. As it rises, the kinds that grow the tree get less likely and
the kinds that shrink it get more likely. Which kinds those are is set by
grows and shrinks in kind.rs. At full pressure, growing kinds are
never drawn. The log shows the pressure on each step as pressure=.
Sizes, names and content
- Sizes (
sizes.rs). A new file is empty, or falls in a small, medium or large band, chosen by weight. Inside the band the size is log-uniform, so small files are common and big ones rare. Appends, overwritten ranges and truncations use the same idea. - Names (
names.rs). Each name has a style: plain, with spaces, a dotfile, unicode, long, or awkward. Names are unique in their directory even when case is ignored and unicode is normalised, so the tree is safe on any platform. - Content (
content.rs). Most bytes are random. A fraction (content.pattern_fraction) uses a pattern instead: zeros, one repeated byte, or a repeated block.
The seed
All choices come from a generator seeded by --seed. The bytes of file
content come from a second generator, seeded by one draw from the first.
The functions that draw sizes and names take the same number of draws
whatever they return. So two runs that differ only in what the caps allow
stay in step.
Resume
The state file records the generator, the last kind and the anchor
(crates/filegen/src/state.rs). On --resume, filegen does not trust its
picture of the tree. It walks the tree again to rebuild its model
(model.rs, walk.rs), then carries on from the saved generator. If the
tree is as the last run left it, the result is the same as a run that
never stopped. If someone changed the tree in between, the run goes on
from the changed tree. It is still repeatable, but no longer identical.
Platforms
Every call into the operating system sits in one module per system:
crates/filegen/src/platform/unix.rs and platform/windows.rs, behind
the plain functions of platform/mod.rs. A build has one of them, so nothing
dispatches at run time. No file outside platform/ names nix, libc,
xattr, std::os::unix or std::os::windows, or a Windows crate: a test
(tests/platform_rule.rs) fails when one does. Other code asks the
platform’s constants and functions instead, for instance MAX_LINKS,
name_ok or EDGE_NAMES. On Unix each of them leaves filegen as it was
before Windows.
What a machine can do is Caps (caps.rs): symlinks and sparse. A run
finds them once, at the start, with platform::probe_caps. On Unix that
tries nothing and returns every capability. On Windows it tries to make a
symlink and to mark a file sparse, in the tree for a real run and in the
output directory for a dry run. caps::disabled then names the kinds that
cannot run on this system with these capabilities, and caps::without
sets their weights to 0 before the chain is built. One notice names them.
That is why a single config serves both systems, and why the choice of kinds
differs between systems: the seed’s run is the same only for the same
platform family and capability set.
The state file records the platform and the capabilities (format_version
4), and a resume refuses a state whose values differ from this machine’s, in
run.rs. A version 3 state is read as a Unix state with every capability
(state.rs).
Names are bytes outside the platform module. On Windows they are WTF-8, made
and read by wtf8.rs, which is plain safe code that every build compiles and
tests. names.rs draws the edge names (an unpaired surrogate, a reserved
device name) only where platform::EDGE_NAMES is set, and takes no draw from
the generator elsewhere, so the names a seed gives on Unix are unchanged.
Ctrl-C is the one thing here that differs in kind. On Unix a signal handler
sets a flag that the loop reads between steps. On Windows the ctrlc crate
does the same for console events, but it does not say which event arrived, so
the log names all of them Ctrl-C. Closing the console window, logoff and
shutdown are such events too, and Windows ends the process shortly after
the handler returns, so a state save is not guaranteed for those.
The Windows module has two unsafe blocks, one reading a reparse point’s tag
(GetFileInformationByHandleEx) and one for DeviceIoControl, which marks a
file sparse and zeroes a range. Miri cannot run either: it cannot make system
calls, and the nightly job runs on Linux. Their tests cover them. punch_hole
is crate-private, because the soundness argument of the second block holds
only for files this crate opens itself.
Tuning without code
Most changes need no code. Use --config with a YAML file, or --set with
a dotted key, as described on the filegen page.
One weight is one cell of the table: previous kind, then next kind. This
makes a hard link much more likely right after a create_file. It is a
valid one-step check:
filegen run --seed 1 --steps 1 --dry-run --out-dir ~/fg \
--set weights.create_file.hardlink=10 ~/src-tree
irsync-stress and irsync-netstress pass the
same keys through with --filegen-set. To raise a whole column you need one
cell per row, so crates/stress/tools/matrix.sh has a small shell function, col, that
writes them all. col hardlink 10 expands to
--filegen-set weights.create_file.hardlink=10, and the same for the other
21 rows. Each campaign row there is a few of these.
Extending filegen
filegen can be changed. Two kinds of change are expected:
- to cover a new critical user journey: a sequence of filesystem operations that matters to real users,
- to cover a feature that only some filesystems have.
Where the change goes depends on its kind.
A new sequence of existing operations. Often no code is needed. The
sequence is a pattern in the table: raise the weight from one kind to the
next. If it must be the default, edit DEFAULT_TABLE in config.rs. A
test in chain.rs checks the shape of the default table, so keep it
passing.
A new operation. Add it in these places:
- A variant in
OpKindinkind.rs. UpdateALL,name, and the array sizes that say 22. Decide if itgrows,shrinks, and whether it isdefault_enabled. - A row and a column in
DEFAULT_TABLEinconfig.rs. A kind that is off by default has a zero column. - Its config keys, if it has any, as a new struct in
config.rs, next toChmodConfigorXattrConfig. - The operation itself, a function in a file under
crates/filegen/src/ops/(file.rs,tree.rs,link.rsormeta.rs), and a line for it indispatchinops/mod.rs. It picks a target with the functions inpick.rs, changes the disk, and returns anAppliedthat says what happened, so the log and the model stay right. It must not touch the disk in a dry run, but it must make the same random draws and the same model updates as a real run (see the top ofops/mod.rs). - The model. If the operation creates something the model has no node
kind for, add one to
NodeKindinmodel.rs, and teachwalk.rsto see it.
A call into the operating system. Put it in platform/, as a function
that both unix.rs and windows.rs provide. Where a system cannot do the
thing, add a capability or list the kind in caps::disabled, so the weight
becomes 0 there.
A filesystem-specific feature. Make it a new OpKind, off by default.
Such an operation should return NoTarget when it has nothing to do, as
set_xattr does when xattr.names is empty and mknod does unless run as
root. Filegen then draws another kind.
The effect must be observable
A new effect only helps if fileset check can see it. Otherwise the
stress loop cannot tell whether the sync carried it.
By default, fileset check compares type, content, symlink target, device
numbers, mode, mtime and size. Link count, owner, group and extended
attributes are compared only with --paranoid or --require. Holes in
sparse files are not recorded at all.
So before adding an operation, ask what in that list it changes. If it changes something fileset does not compare by default, either fileset needs a matching change, or the stress run must ask for the stronger check. If fileset cannot see it at all, the operation will run but prove nothing.
Stress testing
Part of Testing: the loopback stress loop.
irsync-stress runs the loop that filegen, fileset and irsync were built
for. It starts an irsync daemon on loopback, fills a source tree with
filegen, records it with fileset init, then repeats: sync
with the irsync client, compare the two manifests, run fileset check on
the destination, mutate the source with filegen and update its manifest. An
iteration where the sync, the manifest comparison or the check fails is
reported and, unless --keep-going is given, ends the run. It touches no
network beyond loopback; irsync-netstress runs the same loop
over a simulated bad network.
The design is in 2026-10-21-stress-harness-design.md, the calls made while building it and the bugs it found in IRSYNC_HARNESS_DECISIONS.md. Hunting bugs is the strategy for making it find more.
Run the loop
Build the workspace, so that irsync, filegen and fileset sit next to
irsync-stress:
cargo build --release --workspace
Then run it with a root directory that does not exist yet, or is empty:
target/release/irsync-stress --direction push --iterations 20 /tmp/stress-push
target/release/irsync-stress --direction pull --seed 7 --keep-going /tmp/stress-pull -- --parallel 4
target/release/irsync-stress --direction push --max-total-size 8M --max-file-size 1M /tmp/small
The root is never deleted, on success or failure. A run without --seed
draws one and prints it in the header; run.toml in the root records it
with every other setting.
After a failure
Look at, in this order:
ROOT/run.toml: seed, direction, sizes, extra client arguments, tool versions, and the daemon’sEndpointId, address and pid. It is enough to repeat the run.- The two manifests.
SRC/data/.fileset.sqliteis what the destination should have matched;DST/data/.fileset.sqliteis what was checked. Inspect them withfileset, or comparelogs/iter-NNNN.manifest.blake3. logs/iter-NNNN.check.txt: whatfileset checkfound (ADD,DEL,CHGlines and a summary).logs/iter-NNNN.client.log: the client’s output for that iteration. Inlogs/daemon.logthe line=== iteration N ===marks where that iteration starts, so the daemon’s side of the same sync can be read.
The daemon and client logs contain ANSI colour codes from irsync’s tracing
output. Read them with less -R, or strip them with
sed 's/\x1b\[[0-9;]*m//g' before searching.
From a failed iteration to a bug report continues from here.
Campaign tools
crates/stress/tools/breadth.sh runs a breadth sweep: many seeds, short
runs, both directions, several runs at a time. It deletes the root of every
passing run and keeps the root of every failing one. Its environment
variables, with their defaults:
| Variable | Meaning | Default |
|---|---|---|
BIN | Directory with irsync-stress, irsync, filegen and fileset. | target/release |
OUT | Where roots, per-run output and summary.txt go. | ~/work/irsync-breadth |
SEEDS | Seeds to run, as arguments to seq. | 1 50 |
JOBS | Runs at the same time. | 8 |
ITER, STEPS, TOTAL, FILE | Iterations, filegen steps, --max-total-size and --max-file-size of each run. | 20, 200, 4G, 256M |
CLIENT | Arguments for the irsync client, after --. | --idle-timeout 300 |
CHECK | A command run as $CHECK <root> after each passing run; if it fails, the run counts as failed (exit=3) and its root is kept. | none |
DURATION | A time budget in seconds. Once it has passed, no new run starts, and the runs not started get no line in summary.txt. Runs already going finish. | none |
Extra arguments go to every irsync-stress run, before the root. Each run
needs up to twice TOTAL on disk while it runs.
crates/stress/tools/matrix.sh runs the campaign
matrix, one breadth sweep per row. The
rows are hardlink, rename, rename-off, sparse, metadata,
timestamps, symlinks, deletion, listing, longnames, parallel1,
parallel512, checksum, minimal, bigfile, paranoid, concurrent,
concurrent-paranoid, net-concurrent and net-concurrent-paranoid. The
last four write to the source during the sync and take an hour each; see
Writing during the sync.
The two net-* rows run netstress/tools/sweep.sh and need the fault build
(NETBIN names its directory).
matrix.sh hardlink rename runs only those rows; with DRY=1 it only checks that filegen
accepts every row’s settings. Each passing run is checked with
tools/clean-check.sh, which runs tools/paranoid-check.sh (a
fileset check --paranoid of the final destination against the source
manifest, link counts included) and then asserts that no .irsync.*.part
is left in either tree. The rows before concurrent take about three hours
on a 16-core Mac; each of the four concurrent rows is capped at one hour by
DURATION.
The paranoid row passes --paranoid. The harness changes the source only
between syncs, so this row checks that the --paranoid code paths sync a
quiet tree correctly; it does not test catching a file that changes during
the sync. Binaries built by cargo test --workspace have the test-hooks feature, and there --paranoid never
clones, so the row tests the second-hash path; cargo build --release
binaries clone where the filesystem can.
Reference
Command
irsync-stress [OPTIONS] --direction <DIRECTION> <ROOT> [-- <CLIENT_ARGS>...]
<ROOT> is created if missing; it must be empty if it exists.
| Option | Meaning | Default |
|---|---|---|
--direction <push|pull> | Which way the client moves data (required). On a push the source tree is ROOT/SRC/data and the daemon serves ROOT/DST/data; on a pull the roles are swapped. | required |
--iterations <N> | Sync-and-verify rounds. | 10 |
--seed <S> | Seed for filegen, printed in the header. | random |
--steps <N> | filegen operations per fill or mutation. | 100 |
--max-total-size <SIZE>, --max-file-size <SIZE> | Passed to filegen verbatim. filegen refuses a per-file limit above the total, so a small --max-total-size needs a --max-file-size as well. | filegen’s: 25G, 256M |
--filegen-set <KEY=VALUE> | An extra --set for every filegen run; repeatable. Example: --filegen-set names.max_len=200. | none |
--log-level <LEVEL> | Log level for the daemon and the client. | debug |
--keep-going | Carry on after a failed iteration instead of stopping. | off |
--irsync <PATH>, --filegen <PATH>, --fileset <PATH> | Use this binary instead of looking one up. | lookup |
-- <ARGS>... | Appended to every irsync client command line. | none |
The tools are looked up next to the irsync-stress binary first, then on
PATH. run.toml records the path and --version output of each.
The client runs with -a -H --delete --reconnect 0, --address set to the
daemon’s loopback address, and its own --identity and an empty
--config, then the arguments after --. The harness sets no inactivity
timeout, so a hung sync hangs the run; -- --idle-timeout N makes such a client
fail instead, and the harness then exits 2.
Output
A header, one line per iteration, a footer:
irsync-stress
root: /path/to/run
seed: 3
direction: push
endpoint: 716a53cc4cea6705494da4d3b72cae40cfa658440e2e1fe4afba1f1bfbc2a5bb
address: 127.0.0.1:50357
iter 0001/0003 sync 0.2s exit 0 manifest ok check ok
iter 0002/0003 sync 0.3s exit 0 manifest ok check ok
iter 0003/0003 sync 0.2s exit 0 manifest ok check ok
passed=3 failed=0 elapsed=1.1s
A failed iteration looks like this, followed by the path of its check report:
iter 0002/0015 sync 1.3s exit 23 manifest ok check FAILED (added=0 deleted=1 changed=0)
Layout
ROOT/
run.toml parameters of the run, enough to repeat it
SRC/
config/ irsync.toml
data/ the tree filegen mutates; its manifest is data/.fileset.sqlite
DST/
config/ the other side's config files
data/ where the tree arrives; checked here
filegen/ filegen's log and state file (outside both trees)
logs/
daemon.log daemon output for the whole run, with iteration markers
ping.client.log client log of the sentinel round
filegen.stderr.log filegen's stderr, appended by every filegen run
iter-0001.client.log client log per iteration
iter-0001.check.txt fileset check output per iteration
iter-0001.manifest.blake3 hashes of both manifests per iteration
Exit codes
| Code | Meaning |
|---|---|
0 | Every iteration passed. |
1 | At least one iteration failed: client exit 23, manifests differ, or fileset check found differences. |
2 | The harness could not do its job: bad arguments, a root that is not empty, a missing tool, a daemon that did not start, a tool failing, or the client exiting with anything other than 0 or 23. |
130 | Interrupted by SIGINT or SIGTERM. The client, filegen or fileset run in progress, and the daemon, are sent SIGINT first. |
With --concurrent the rules and exit codes differ; see
Writing during the sync.
A client exit of 23 (partial transfer) is a failed iteration, not a harness
error; the manifest comparison and the check still run for it. Any other
client exit, such as 25 from --max-delete, is a harness error.
Bugs the harness has found
Each is fixed, with a regression test in the irsync crate.
IRSYNC_HARNESS_DECISIONS.md
has the full record of each.
| Bug | Found by | Regression tests |
|---|---|---|
A file name longer than about 242 bytes could not be transferred: its staging name .irsync.<name>.part exceeded NAME_MAX. | a default run | tests/posix_extras.rs name_max_entries_transfer, tests/gc.rs gc_handles_shortened_part_names, the temp_names tests in tests/recv.rs |
| A FIFO whose only change was its modification time was never updated. | the acceptance run | tests/posix_extras.rs fifo_mtime_is_applied_and_updated, tests/plan.rs special_metadata_only_difference_is_meta_only |
One side’s long local work, such as the daemon hashing with -c, was invisible to the other side’s inactivity watchdog. | the bigfile matrix row | tests/resume.rs peer_local_progress_resets_idle_watchdog |
| Metadata applied to a destination file with several links reached the names the source had unlinked. | the hardlink matrix row | tests/posix_extras.rs link_broken_at_source_with_equal_content_is_broken_at_destination, mode_change_does_not_reach_a_destination_link_outside_the_tree |
| A file whose mode, owner or group changed between the listing and the hash was placed with the listing’s. | --concurrent | tests/change_detection.rs *_before_hash_places_the_new_*, tests/ids_e2e.rs chunk_list_ids_are_mapped_by_name_unless_numeric_ids |
With -H, a name replaced or renamed away after the listing was still linked to the copy of the file it used to name. | --concurrent | tests/change_detection.rs replaced_link_is_sent_as_its_own_file*, link_renamed_away_is_not_linked*, tests/posix_extras.rs links_to_files_placed_before_a_drop_are_checked |
Tests
cargo test -p stress runs unit tests and an end-to-end test that starts a
real daemon and the real tools. That test needs the other binaries, which
cargo test -p stress alone does not build: run cargo build --workspace
first, or use cargo test --workspace.
Hunting bugs
Part of Testing: campaigns, the slowest layer.
A strategy for turning irsync-stress from a loop that passes into a loop that finds bugs. It builds on what the harness has found so far (IRSYNC_HARNESS_DECISIONS.md), on the knobs that filegen, fileset and the irsync client expose, and on irsync’s list of open points (section 2 of IRSYNC_DECISIONS.md), which is a map of where the ice is thin.
Network faults (loss, delay, dead zones that force a reconnect and resume) are covered by a separate rig, irsync-netstress.
The commands assume a release build in target/release and roots on a
filesystem with room for twice the size cap.
What the loop can and cannot see
Every bug the harness finds has to pass three filters. Knowing them tells you where to push.
- filegen must provoke it. Only operations with a non-zero weight
happen.
set_xattr,chownandmknodare off by default;mkfifoandpunch_holeare rare (weights 0.5 and up to 1 in rows that sum to about 100). A bug in hard-link handling needs hard links in the tree, and at the default weight of about 1% a default 10-iteration run makes about 10 of them. - fileset check must observe it. The harness runs the default tier:
type, content, symlink target, device numbers, mode, mtime, size. It does
not compare
nlink,uid,gidorxattr, so a hard-link group that arrives as independent copies with the right bytes passes. Disk allocation (sparseness) is not recorded at all. Nothing checks the destination’s.partleftovers, index rows or session files. - A known bug must not drown it. Some bugs compound: once their trigger exists in the source, every later iteration fails for the same reason, and anything else has to be found by hand underneath them. In the harness’s acceptance run all 1083 failed iterations came from two such bugs. Fix or neutralise a compounding bug before investing in campaigns: a harness whose default run fails most iterations on a known cause gives no signal on anything new.
A compounding bug is neutralised with --filegen-set, by keeping filegen
from making its trigger. Long names off: --filegen-set names.max_len=200.
An operation off: its column must be zero in every row of filegen’s
transition matrix:
FG=()
for k in create_file append truncate overwrite_range rewrite punch_hole delete_file \
mkdir rmdir remove_tree rename rename_over symlink repoint_symlink \
delete_symlink hardlink mkfifo chmod set_mtime set_xattr chown mknod; do
FG+=(--filegen-set "weights.$k.mkfifo=0")
done
irsync-stress --direction push "${FG[@]}" ROOT
The same loop with another weight biases an operation instead of switching
it off; matrix.sh does this with its col function.
The harness never deletes a root, and both manifests survive, so the observation filter can be widened after a run at no cost:
fileset check -q --paranoid --manifest ROOT/SRC/data/.fileset.sqlite ROOT/DST/data
fileset check -q --relaxed --require nlink --manifest ROOT/SRC/data/.fileset.sqlite ROOT/DST/data
du -s ROOT/SRC/data ROOT/DST/data # allocated blocks: sparse preservation
Do this on every finished run; crates/stress/tools/paranoid-check.sh ROOT
runs the first. A destination that uses fewer blocks than the source is
irsync skipping all-zero chunks (R3), not a fault; a destination that uses
more blocks with -S passed would be one.
Breadth before depth: many seeds, short runs
Because failures compound, a 300-iteration run mostly re-reports its first bug. Many short runs find more distinct bugs per machine-hour:
crates/stress/tools/breadth.sh # seeds 1 to 50, both directions, 8 at a time
grep -v 'exit=0' ~/work/irsync-breadth/summary.txt # runs with a failure or error
The script takes BIN, OUT, SEEDS, JOBS, the run size and the client
arguments from the environment, passes extra arguments to irsync-stress,
deletes the root of every passing run and keeps the root of every failing
one (Campaign tools lists the variables). At the
defaults, a run took about 160 s on a 32-core machine, and the eight live
roots used 23 to 26 GB of disk.
It runs every seed in both directions. The same seed produces the same source tree in both, so a seed that fails on push and passes on pull puts the bug in the daemon-side receiver, and the reverse puts it in the client receiver. That is the cheapest localisation the harness offers.
Then go deep on a few seeds: 300 to 1000 iterations with --keep-going,
looking for bugs that need accumulation: index growth, session and GC
state, .part files left behind, and the daemon’s memory over time (ps
it hourly).
The campaign matrix
Each row aims the harness at a part of irsync that the default run barely
touches. Run each as a breadth sweep, in both directions.
crates/stress/tools/matrix.sh runs the rows it names in the last column
(Campaign tools). --filegen-set takes dotted
YAML paths; weights are per transition row, so biasing an operation means
setting its column in every row, as above.
| Target in irsync | How to aim the harness | What a failure looks like | matrix.sh row |
|---|---|---|---|
| Hard-link final pass (R23); stale target content when the target failed at planning time; link groups across directories | hardlink weight 10 in every row, rename and rename_over 8; post-run --require nlink | nlink= differences in paranoid, or a short-named member with old content for one iteration | hardlink |
| Rename detection and content reuse | rename 15, rename_over 10, overwrite_range 5; run the same seed with and without -- --no-rename-detection | A failure only with detection on is a reuse bug; only with it off, a plain transfer bug | rename, rename-off |
Resume and chunk adoption of .part files | -- --idle-timeout 5 with max_file_size 2G and --bwlimit 20m, so transfers outlive the timeout; or kill the client mid-sync and re-run the same invocation | Client fails (harness exit 2), or content differs after the adopted chunks | none |
Sparse files (R3, -S) | punch_hole 10, content.pattern_fraction=0.5 (zero blocks), -- -S; compare du -s of both trees | Destination allocates more than the source, or holes become data | sparse |
Metadata: special mode bits, read-only files, the u+w restore path | chmod.special_weight=0.5, chmod weight 10; modes 0444 and 0555 are already in the list | mode= lines; a .part stranded read-only in the destination (find DST -name '.irsync.*.part') | metadata |
| Timestamps: future, pre-epoch, sub-second | mtime: {future: 0.5, future_years: 50} and distant_years: 70 (1956, before the epoch) | mtime= lines on regular files or directories | timestamps |
| Directory mtime after children change | The default mix; mtime is in the default tier. Look for CHG <dir> mtime= | Directories whose mtime a child write reset after metadata was applied | none |
| Symlinks: dangling, absolute, pointing at directories, repointed | symlink: {dangling: 0.5, absolute: 0.5}, repoint_symlink 10 | target= lines; a symlink followed instead of recreated (a file where a link should be) | symlinks |
Deletion passes and --max-delete | remove_tree 5 with remove_tree_max_entries=5000; -- --delete-before; separately -- --max-delete 50 | With --delete-before, watch daemon memory. Client exit 25 is a harness error (exit 2), so --max-delete needs a harness change first | deletion (--delete-before only) |
| Listing size, ordering, out-of-order drops (R7) | --steps 5000, size_distribution.small.weight=0.95, max_depth=64, names.classes.unicode=30, names.classes.awkward=30 | ADD/DEL pairs on names that sort differently under byte order and NFC | listing |
| Long names and paths | names.classes.long=30, max_depth=64; further names.max_len=255, max_path_len=3900 | File name too long or ENAMETOOLONG, on index paths rather than file names | longnames |
| Concurrency and backpressure (R31) | -- --parallel 1 (serialises; finds ordering bugs) and -- --parallel 512 with 5000-step iterations of small files | Daemon memory growth across iterations; a hang that --idle-timeout turns into exit 2 | parallel1, parallel512 |
| Inactivity watchdog against long local work (R35) | Large files (max_file_size=8G, size_distribution.large_weight=1), -- -c --idle-timeout 10, so the receiver hashes before answering | A spurious reconnect, visible as a failed client with --reconnect 0 | bigfile |
| Quick check against checksum | Run the same seed with and without -- -c; a difference means the size-and-mtime shortcut skipped a changed file | Pass with -c, fail without | checksum |
The --paranoid code paths (clones, second hash, final re-check) on a source that nothing writes to during the sync; the harness changes the tree only between syncs, so this does not test catching a change | -- --paranoid with the default mix; run on a release build to test clones, on a test-hooks build to test the second hash | A failure the same seed does not show without --paranoid; a .irsync-clones-* folder left in the source tree | paranoid |
Source files that change during the sync: the change checks (stat after hashing, the ask before placing, --paranoid’s clone, second hash and final re-check) | --concurrent: filegen writes to the source while irsync syncs it, and every destination path is judged against the states the source held (see below); push and pull, with and without -- --paranoid | A path named with the rule it broke: no state the source held, or content and times disagree | concurrent, concurrent-paranoid |
| The same, over a bad network | irsync-netstress --concurrent through crates/netstress/tools/sweep.sh, on the fault build | As above; also exit 3 when the faults never bit | net-concurrent, net-concurrent-paranoid |
| Minimal deltas | --steps 1 --iterations 500 | Each failing iteration names exactly one filegen operation in filegen/filegen-<seed>.log | minimal |
| Idle syncs | --steps 0 runs, but also empties the fill, so the tree is empty; a populated idle sync needs a separate fill step count (a harness change) | A sync of an unchanged tree that transfers anything (check -- --stats) is an index bug | none |
| xattrs | set_xattr weight 5, post-run --require xattr | Expected to fail: irsync has no -X. Run only to document the gap | none |
Two differential patterns recur in the table and are worth stating on
their own: same seed, one flag flipped (-c, --no-rename-detection,
--no-resume, -S, --delete-before, --parallel 1) and same seed,
other direction. A bug that appears on exactly one side of such a pair is
half diagnosed before anyone reads a log.
Writing during the sync (--concurrent)
The loop above changes the source and syncs it one after the other.
--concurrent, on irsync-stress and on irsync-netstress, makes filegen
write to the source while irsync syncs it. The goal: no destination file
is ever a state the source never held. On a pull, filegen writes to the
server’s tree while the daemon sends it.
What a round does
- Pick a pace for filegen from the seed:
fast(never pauses),steady:N(N steps a second) orbursts:ON:OFF(milliseconds of writing, then of quiet).--pacefixes it for the whole run. - Copy the source tree (a reflink copy where the filesystem can).
- Start filegen in the background, then start the sync.
- When irsync exits, stop filegen between two steps.
- Rebuild the source’s history from the copy and filegen’s log (its
post=andpost_to=fields give the stat after each step), and judge every destination path against it. - Run one more sync with nothing writing. It must exit 0 and leave an exact copy.
The seed fixes the random choices. How many steps filegen gets through
before irsync exits depends on timing, so each round’s pace and step count
go to logs/rounds.tsv. The race itself cannot be replayed: a rerun may
not fail again. The kept files are the evidence.
The rules
A destination path passes when it is a state the source really held:
- its state at the start of the round, or after any complete filegen step;
- a state in the middle of a step, as filegen writes it: a truncated file, or the old bytes followed by a prefix of the new ones.
A path fails when:
- it matches no such state (
no state the source held). Bytes from two steps never mix: that is a torn file; - its size and modification time match a state but its content or mode do
not (
content and times disagree). The next normal sync would skip it forever; - it exists but the source never held it.
Mode and owner (when run as root) are judged too. Directories are judged
on existence and permissions only; hard-link groups are left to the quiet
sync. Exit 23 is accepted only when every file irsync gave up on is one
filegen touched during that sync. The harness learns this from
IRSYNC_FILE_REPORT, a variable it sets so irsync writes a small report of
the files it retried and gave up on. It is for the harness only, so it is
not in the command-line reference.
Exit codes
| Code | Meaning |
|---|---|
0 | Every round passed. |
1 | A round failed. |
2 | The harness itself could not do its job: filegen failed, the replay did not match filegen’s log, or a file could not be read or written. |
3 | irsync-netstress only: the faults did not bite. |
4 | The concurrent writes did not bite: no file changed during a sync was ever placed. The run tested nothing. |
Exit 0, 23 and 24 from the sync during the writes are judged as above.
Any other exit, a crash (a signal) or a hang (the client’s --idle-timeout)
fails the round, as does a quiet sync that exits anything but 0. These are
failed rounds, not harness errors: the run exits 1, the round is kept and
the rerun printed, and --keep-going goes on to the next round. A daemon
that dies fails its round too, but then ends the run (exit 1), since
nothing can sync after it. In irsync-netstress, a client log without
netsim active is still a harness error (exit 2).
Files kept, and the rerun
A failed round is kept as ROOT/round-NNNN/: start/ (the source at the
start of the round) and filegen’s state, beside ROOT/logs. When the judge
failed a path, it also holds dest/, the destination as judged, before the
quiet sync repaired it. A round that failed for another reason has no
dest/; after a dead daemon, ROOT/DST/data is the destination as the
round left it. The output names
each failing path with its rule (the first 20), then judge report:
(logs/iter-NNNN.judge.txt, one path<TAB>rule line per failure),
round kept in: and rerun:. The rerun command uses a fresh root and --replay-rounds ROOT/logs/rounds.tsv, so
every round starts from the same source tree with the same paces and step
counts. --keep-going carries on past a failed round.
The command looks like this (the new root is the old one with .rerun
added):
irsync-stress --direction pull --iterations 5 --seed 99 --steps 100 \
--concurrent --pace fast --replay-rounds ~/work/run/logs/rounds.tsv \
~/work/run.rerun -- --paranoid
Bugs the concurrent rows found
The first full-pace runs found two real irsync bugs, both now fixed: a mode (or owner) taken from the walk instead of the file that was hashed, and a hard link made to a name that was replaced or renamed away after the walk. A failure of either kind is now a new failure.
One more failure is a known limit, not a bug to chase: on a filesystem with
coarse timestamps, two writes in the same clock tick can leave a file’s
size and modification time unchanged, so irsync’s checks cannot see the
second one. The judge then reports content and times disagree. See
Coarse timestamps.
The self-test: does the checker bite?
A checker that cannot fail is worth nothing. A test-hooks build of irsync
has a switch, IRSYNC_TEST_NO_CHANGE_CHECKS=1, that turns all the change
checks off. With it on, a concurrent run must produce a torn file and fail:
Build the release tools first (cargo build --release --workspace), then:
cargo build --release -p irsync --features test-hooks --target-dir target/selftest
IRSYNC_TEST_NO_CHANGE_CHECKS=1 target/release/irsync-stress --concurrent \
--irsync target/selftest/release/irsync --direction push --iterations 20 ~/work/selftest
It must exit 1. Look at the report: the failure that proves the checker
bites is a torn file (no state the source held). If a run fails only in
other ways, try more seeds (--seed) until a torn file shows up.
If the run passes, the checker is not catching what it should: stop and
find out why. It depends on timing, so it is a manual step and not a
cargo test; the checker’s own rules have deterministic tests.
Size and pressure
filegen damps growth above 80% of max_total_size, so a long run sits at
the cap with deletions boosted. Choose the cap for the regime you want:
- Small cap, many files (
--max-total-size 512M --max-file-size 8M): metadata, naming, listing and deletion bugs; fast iterations, hundreds of seeds per hour. - Large cap, few files (
--max-total-size 50G --max-file-size 8G): chunking, resume, sparse handling, hashing time, watchdogs. - Default (25G and 256M): the steady state of the acceptance run, about 3 s per sync and 30 minutes for 300 iterations on a disk-backed root.
A root on tmpfs is fast but competes with RAM; cap each concurrent run at a quarter of the free tmpfs space.
Harness extensions
These need changes to the stress crate, ordered by bugs per effort. Each
should come with its own end-to-end test, like the existing one.
- A
--check-argpassthrough (or--paranoid), sofileset checkruns with--require nlinkand the like inside the loop, not after it. The harness runsfileset check -q;breadth.sh’sCHECKhook withparanoid-check.shcovers only the final state of passing runs. - Treat client exit 25 like 23.
--max-deletecannot be stress-tested while exit 25 is a harness error. - Kill and resume.
--kill-after <secs>sends SIGKILL to the client once per iteration after that delay, then re-runs the identical command and verifies. This is the largest untested surface: resume,.partadoption, hash-verified chunk reuse, an orphaned finalize during a reconnect. irsync-netstress covers the network half (a dead zone that forces a reconnect and resume), not a killed client. - Destination drift. Before each sync, run a second filegen (its own
seed and state) on
DST/datawith a small step count. irsync must then repair the destination, andfileset checkstill expects the source. This exercises the planner’s changed-or-equal decisions on files irsync did not write, including same size with different content and the mtime shortcut (compare with and without-c). - Two clients, one export. Run the same push from two client setups at
once. The known cost is 60 s per overlapping file before
PART_BUSY; unknown is whether the result is ever wrong. - Split roots (
--dst-root), so source and destination can be on different filesystems: ext4 to tmpfs, to xfs, to btrfs, and on macOS to a case-insensitive APFS volume. Timestamp granularity, case folding and NFC normalisation depend on the filesystem, and filegen draws names that are unique under folding and NFC for this reason. - Disk full. A loop-mounted image of a fixed size as the destination. The run should fail cleanly with exit 23 and recover once space returns, and never leave a torn file that passes the next check.
- Negative checks after every iteration. No
.irsync.*.partremains in the destination, and the index and session directories do not grow without bound across iterations.clean-check.shchecks the first after a passing run.
From a failed iteration to a bug report
run.tomlgives the seed, direction, sizes and extra arguments. Re-run with the same seed and--iterations N, where N is the failing iteration; the tree is deterministic, so it fails the same way.- Shrink: same seed,
--steps 1, iterations multiplied accordingly, until one iteration holds one filegen operation. Itsstep=line infilegen/filegen-<seed>.logis the trigger. - Localise: flip the direction, then flip one client flag at a time (see the campaign matrix). Record which side and which flag.
- Read
logs/iter-NNNN.client.logand the=== iteration N ===section oflogs/daemon.log. Both carry colour codes;sed 's/\x1b\[[0-9;]*m//g'strips them forgrep. - Write the finding into
IRSYNC_HARNESS_DECISIONS.md
under “Known irsync bugs found by the harness”, in the form of the
entries there: what filegen did, what the check reported, the hypothesis
marked as such, the decision. Add a regression test to the
irsynccrate before fixing.
A campaign is only readable when known failures are subtracted
automatically. That takes a classifier script that attributes each failure
to a known cause by its signature; the repository has none. Keep it
under crates/stress/tools/ and extend it with each new signature.
Cadence
- Every change to irsync: CI runs the full regression
(
cargo test --workspace --all-features -- --include-ignored), which includes the harness’s end-to-end test. - Nightly: a breadth sweep in both directions with the matrix row of the week, 50 seeds, 20 iterations, small cap.
- Weekly: two deep runs (push and pull, 1000 iterations, default cap) and one large-file run, with the daemon’s memory sampled per iteration.
- Per irsync fix: the seed that found the bug, re-run as part of the
fix, and its matrix row’s settings added to the harness’s end-to-end
test (
crates/stress/tests/e2e.rs) if they are cheap enough.
The measure is distinct root causes found per machine-hour, and the ledger is the “Known irsync bugs found by the harness” section. When a nightly sweep has run clean on a matrix row for two weeks, move that row to weekly and bring in the next harness extension.
Network stress with netstress
Part of Testing: the stress loop over a simulated bad network.
irsync-netstress tests irsync over a bad network. It runs the same
sync-and-check loop as irsync-stress, but every packet between
the irsync client and the daemon passes through a simulated link: limited
speed, a queue that overflows, delay, bursts of loss, and on some profiles a
dead zone that cuts the link for 20 to 60 seconds.
The question it answers: when the network is bad, does irsync still deliver exactly the right files, reconnect and resume when the link drops, and keep both the client and the daemon running? Slow syncs and warnings in the log are expected. Wrong files, failed syncs, crashes or leftover partial files are not.
It is a separate rig; irsync-stress tests over loopback without faults. How netstress works explains the simulated network inside. The design is in 2026-11-06-network-faults-design.md; the calls made while building it, and the results of the first real runs, are in NETSTRESS_DECISIONS.md.
Use
Quick start
# 1. Build the fault binaries (once, and after every change to irsync).
cargo build --release --workspace --features netsim --target-dir target/netsim
# 2. A short smoke run, about a minute: no shaping, one 6 s dead zone per sync.
target/netsim/release/irsync-netstress --profile test-blackout --direction push ~/work/ns-smoke
# 3. A real run: a moving vehicle on 4G, pushing. Up to about 10 to 15 minutes.
target/netsim/release/irsync-netstress --profile 4g-vehicle --direction push --seed 1 ~/work/ns-4g-push
The root directory (the last argument) must not exist yet, or must be
empty. It is never deleted. Use a short path such as ~/work/...: filegen
makes deep trees and refuses to run when the root’s path is long enough to
push files past the system’s path length limit.
The fault build
The fault layer is compiled into irsync only when the cargo feature
netsim is on. A normal build has none of it, and never reads the
IRSYNC_NETSIM variable. Build the fault binaries into their own target
directory:
cargo build --release --workspace --features netsim --target-dir target/netsim
- The binaries land in
target/netsim/release/:irsync,irsync-netstress,irsync-stress,filegenandfileset. - The separate target directory keeps
target/releasefree of fault code, so a fault build can never be mistaken for a real one. - Write the command exactly as shown.
--features irsync/netsimlooks the same but builds irsync without the feature, because irsync lists itself as a dev-dependency. - Check it:
target/netsim/release/irsync --versionends with[netsim].irsync-netstresschecks this itself and refuses to start with any other irsync, printing the build command. - A debug build works too (drop
--release, binaries intarget/netsim/debug/), but the link model then costs more CPU and runs take longer.
Rebuild after every change to irsync. The rig uses whatever binary it finds; an old fault build tests old code.
Repeating a run
The seed fixes the file trees exactly and fixes the random choices of the network (which speed, which packet is lost, how long the dead zone lasts). But the network runs on the real clock, and threads do not run in the same order every time, so a repeated run does not replay packet for packet. The same seed gives a run with the same character, not the same run. To repeat one:
irsync-netstress --profile <profile> --direction <dir> --seed <seed> ~/work/new-root
using the values from the failed run’s run.toml. Some hints:
- Run it alone. Several runs at once share the CPU, which changes timing and makes syncs slower.
- If the failure was in iteration N, keep
--iterations Nand let it stop at the first failure (no--keep-going). - Try a few seeds. A failure that shows up on one seed in ten is still a real failure.
- Extra client options go after
--, for example-- --idle-timeout 30to test whether a longer timeout makes a failure go away.
Sweeps
crates/netstress/tools/sweep.sh runs many seeds, both real profiles and both directions, a few
runs at a time, always with --keep-going. It deletes the roots of passing
runs (they can be repeated from their seed) and keeps the roots of failing
ones.
crates/netstress/tools/sweep.sh # seeds 1 to 10, both profiles, both directions
SEEDS="1 3" PROFILES=dsl-video crates/netstress/tools/sweep.sh
JOBS=2 crates/netstress/tools/sweep.sh --iterations 3
| Variable | Meaning | Default |
|---|---|---|
BIN | Directory with irsync-netstress, irsync, filegen, fileset. | target/netsim/release |
OUT | Where roots, outputs and summary.txt go. | ~/work/irsync-netstress-<date> |
SEEDS | Seeds to run, as arguments to seq: "1 10" is 1 to 10, "5 5" is just 5. | 1 10 |
JOBS | Runs at the same time. | 4 |
PROFILES | Profiles to run, separated by spaces. | 4g-vehicle dsl-video |
CLIENT | Arguments for the irsync client, after --. | none |
DURATION | A time budget in seconds. Once it has passed, no new run starts, and the runs not started get no line in summary.txt. Runs already going finish. | none |
Any arguments go to every irsync-netstress run, before the root.
sweep.sh --concurrent runs the concurrent mode:
filegen writes to the source during each sync. matrix.sh has two rows for
it, net-concurrent and net-concurrent-paranoid, each with a one-hour
budget.
It refuses to start without a fault build. For each run it writes
OUT/<profile>-<direction>-<seed>.out (the rig’s output) and adds one line
to OUT/summary.txt:
4g-vehicle push 3 exit=1 passed=9 failed=1 elapsed=1104.2s outages=10
It exits non-zero if any run did not exit 0.
Plan for the time. A full default sweep is 40 runs. With four sharing the
CPU, a dsl-video pull run takes about 4 minutes, a 4g-vehicle run 14
to 23 minutes and a dsl-video push run about 30 (up to 37), because pushes
go up the slow uplink. Expect over three hours at JOBS=4. With
--congestion cubic the dsl-video runs take about half as long and the
4g-vehicle runs up to twice as long, so the total is about the same.
Lower JOBS if syncs slow down enough to cause timeouts of their own.
Reading the logs
The logs contain colour codes; read them with less -R, or strip the codes
before searching with grep.
The fault layer writes these lines, all at warn so they show at any log
level:
| Line | Where | Meaning |
|---|---|---|
netsim active profile=… side=… seed=… stream=… | client and daemon, at start | The fault layer is on, with these settings. |
netsim: dead zone open secs=N | client | The dead zone started; it lasts N seconds. |
netsim: dead zone closed | client | The dead zone ended. It is logged with the first packet after the end, so it may come a little later than N seconds. |
netsim: counts sent=… queue_drops=… loss_drops=… outage_drops=… send_errors=… truncated=… | client and daemon | What happened to this process’s packets so far. Every 10 s while traffic flows, and once at the end. |
netsim: send failed: … | client and daemon | The real socket refused a packet. The first one is at warn, later ones at debug. Should never happen. |
The counts, per process, counting only packets this process sent (except
outage_drops and truncated):
| Count | Meaning |
|---|---|
sent | Packets irsync handed to the fault layer to send. |
queue_drops | Dropped because the simulated queue was full: irsync sent faster than the link could carry. |
loss_drops | Dropped by the random loss. |
outage_drops | Dropped because a handover or the dead zone was on, sent or received. Client only; the daemon’s is always 0. |
send_errors | The real socket refused to send. Should be 0. |
truncated | A received packet was bigger than irsync’s buffer and was dropped. Should be 0. |
The counts tell you whether a failing sync saw the losses the profile
should give. For example, queue_drops far above loss_drops on a push
under dsl-video means irsync kept overfilling the 64 KiB uplink queue.
The daemon’s last counts line is usually its last 10-second report: the
rig stops the daemon without letting it write a final one.
What a normal dead zone looks like in the client log (4G, --idle-timeout 10),
in order:
netsim: dead zone open secs=41- about 10 s later:
no activity; dropping the connection secs=10, thensession failed, thenconnection lost; reconnecting - further reconnect attempts while the zone lasts
netsim: dead zone closedsession started session=<same id> resumed=true
In the daemon log around the same time, expect
connection failed: control stream: connection lost and, from the QUIC
layer, failed closing path err=LastOpenPath. An occasional SendDatagram
warning from iroh is also normal. None of these fail a run.
Useful searches (on a log with colour codes stripped):
# strip colour codes
sed 's/\x1b\[[0-9;]*m//g' logs/iter-0003.client.log > /tmp/iter3.log
# the network story of one sync
grep -E 'netsim|no activity|reconnecting|session started|session failed' /tmp/iter3.log
# every file that failed, and why
grep failed /tmp/iter3.log
# the daemon's side of iteration 3
sed -n '/=== iteration 3 ===/,/=== iteration 4 ===/p' logs/daemon.log
After a failure
Start with the first failed iteration. With --keep-going, later
iterations inherit the damage (for example a .part file left by an
earlier one), so only the first failure says anything clear about its
cause.
- Read the iteration line and the reason line under it.
- Read
run.tomlfor the seed, profile, direction and sizes. - Read the client log of that iteration (see Reading the logs): the network story, then which files failed and with what message.
- Read the daemon log between
=== iteration N ===and the next marker. - For file differences, read
logs/iter-NNNN.check.txt(ADD,DEL,CHGlines), as in irsync-stress.
What each kind of failure usually points at:
| Symptom | Where to look |
|---|---|
reconnect without a dead zone | The client saw 10 s without any packet from the daemon while the link was up. Look at the counts around that time: many drops point at the profile or the link model, few drops point at irsync. |
dead zone did not end in a resumed session | The reconnect worked but a new session started instead of the old one resuming, or the client never got back. Look at what the client logged after dead zone closed. |
partial file left behind | A failed or interrupted file left its .irsync.<name>.part. It usually goes with a client exit 23 earlier in the run. |
Exit 2 with daemon died during iteration N | The daemon crashed. The end of daemon.log has the reason. This is always worth a bug report. |
Exit 2 with irsync client exited N | The client failed in a way that is not a partial transfer: 1 (the whole sync failed, for example the reconnect window ran out), 25 (--max-delete stopped it), or a crash. The client log has the reason. |
| Exit 3 | No sync moved enough data to hit the dead zone. Use a bigger --max-total-size. |
To tell an irsync problem from a problem with the simulation, change one
thing and run the same seed again. If a failure goes away with gentler
numbers in the profile, the profile was too harsh. If it stays even under
test-blackout, which has no shaping at all, look at irsync or the
transport. The first-run findings and the open questions are in
NETSTRESS_DECISIONS.md.
Using the fault layer by hand
The rig is not the only way to use the fault layer. Any irsync from the
fault build turns it on when the IRSYNC_NETSIM variable is set:
IRSYNC_NETSIM=profile=<name>,side=<client|daemon>,seed=<n>,stream=<n>
All four keys are required, in any order. A bad value is an error, not
ignored. An optional fifth key, acks=<immediate|gentle|peer-default>,
changes the ACKs this side asks of the other; see --acks under
Command line.
- Set it on both sides with the same profile and seed,
side=daemonfor the daemon andside=clientfor the client. With the variable set, irsync talks only through the fault layer: no ordinary UDP socket, no relay. A client with the variable cannot reach a daemon without it, and the other way round. streampicks one of many independent fault schedules for the same seed. The rig uses 0 for the daemon and the ping, and the iteration number for each iteration’s client. Use different streams to get different schedules.- The fault layer only works over IPv4 on this machine. Point the client at
the address the daemon prints with
--address 127.0.0.1:<port>. - Give the client a
--reconnectwindow longer than the dead zones (the rig uses5m) and the profile’s--idle-timeout. Without a reconnect window a dead zone simply fails the sync. - Look for
netsim activein each side’s log to be sure it is on.
Changing or adding a profile
The profiles live in two places:
crates/irsync/src/net/netsim/profile.rs: the link in each direction (link()) and the handovers and dead zone (outages()). The fields are documented in the file and explained in How netstress works.crates/netstress/src/profile.rs: the run defaults (iterations, steps, sizes), the client--idle-timeout, and whether the profile has dead zones.
To change numbers, edit those tables and rebuild the fault build. The unit
tests in crates/irsync/src/net/netsim/link.rs and outage.rs check some
profile behaviour (for example that 4G loses about 1% in bursts, and that
dsl-video’s video leaves room for irsync); a big change may need their
bounds updated. Record why in
NETSTRESS_DECISIONS.md.
To add a profile:
- Add a variant to
ProfileNameincrates/irsync/src/net/netsim/mod.rs, and its name toFromStrandDisplaythere. - Add its link and outage parameters in
crates/irsync/src/net/netsim/profile.rs. - Add the same name to
Profileincrates/netstress/src/profile.rs, with its defaults. - Add a unit test in
link.rsoroutage.rsthat checks the behaviour the profile is meant to have. - Document it under Profiles on this page.
Rules that keep a profile useful:
- The client
--idle-timeoutmust be longer than the longest handover and shorter than the shortest dead zone. Then a dead zone always forces a reconnect and a handover never does. For4g-vehiclethat is 2 s < 10 s < 20 s. - A profile without dead zones fails on any reconnect, so its worst stall
(queueing delay plus loss bursts) must stay well under the client
--idle-timeout. - Video-style cross traffic must hold the queue below its size
(
hold_bytes < queue_bytes), or irsync’s packets have no room at all and the link blacks out. Nothing checks this yet. - The dead zone threshold (
dead_zone_after_bytes) must be well under what a typical sync moves, or most syncs never hit it.
Testing the rig
cargo test -p netstress -- --include-ignored # the rig: unit and end-to-end tests
cargo test -p irsync --features netsim # irsync, including the fault layer's own tests
Without --include-ignored, the rig’s slow end-to-end tests are skipped.
They run the real rig
under test-blackout (and one short dsl-video pull). The first time,
they build the fault binaries into target/netsim/debug themselves, which
takes a few minutes.
The fault layer’s own tests:
crates/irsync/src/net/netsim/*.rs: the link model, outages, seeds and addresses.crates/irsync/tests/netsim.rs: client and daemon in one process, on tokio’s paused clock and an in-memory network, sync a 4 MiB file through a dead zone and resume, and push 3 MiB overtest-slowin over a minute of network time; each takes about a second. With the real binaries and noIRSYNC_NETSIM, nothing changes.crates/irsync/tests/netsim_endpoint.rs: an endpoint with the fault layer on offers no ordinary IP or relay address, so no packet can go around it.
Reference
Command line
irsync-netstress [OPTIONS] --direction <DIRECTION> --profile <PROFILE> <ROOT> [-- <CLIENT_ARGS>...]
| Option | Meaning | Default |
|---|---|---|
<ROOT> | Working directory for the run. Created if missing; must be empty if it exists. Never deleted. | required |
--profile <NAME> | The network to simulate: 4g-vehicle, dsl-video, long-rtt or test-blackout. See Profiles. | required |
--direction <push|pull> | Which way the client moves data. On a push the client sends; on a pull the daemon sends. | required |
--iterations <N> | Number of sync-and-check rounds. | the profile’s |
--seed <S> | Seed for the file trees and for the network’s random choices. Printed in the header and saved in run.toml. | random |
--steps <N> | filegen operations per fill and per mutation. | the profile’s |
--max-total-size <SIZE> | Passed to filegen: the most data the tree may hold. | the profile’s |
--max-file-size <SIZE> | Passed to filegen: the largest single file. | the profile’s |
--filegen-set <KEY=VALUE> | An extra filegen --set for every filegen run; repeatable. | none |
--congestion <bbr|cubic> | Write congestion = "<NAME>" into both the daemon’s and the client’s config, so both directions use that congestion control. | irsync’s (bbr) |
--acks <immediate|gentle|peer-default> | The ACKs each side asks of the other: immediate (every packet, within 1 ms), gentle (every second packet, within 1 ms) or peer-default (nothing asked: every second packet or after 25 ms). For measuring them against each other. | irsync’s (immediate) |
--log-level <LEVEL> | Log level for the daemon and the client. | debug |
--keep-going | Carry on after a failed iteration instead of stopping. | off |
--irsync, --filegen, --fileset <PATH> | Use this binary instead of looking one up. The tools are looked up next to irsync-netstress first, then on PATH. | lookup |
-- <ARGS>... | Everything after -- is added to every irsync client command. | none |
What the rig adds to the client command line by itself:
--reconnect 5m: the client may spend up to five minutes reconnecting after the link drops. That is far longer than the longest dead zone (60 s). irsync-stress passes--reconnect 0instead.--idle-timeout <N>, the profile’s value: after N seconds without hearing from the daemon, the client drops the connection and reconnects. It comes before your-- <ARGS>, so-- --idle-timeout 20overrides it.
Examples:
# Five quick rounds of DSL in the pull direction, keep going past failures
irsync-netstress --profile dsl-video --direction pull --iterations 5 --keep-going ~/work/ns-dsl
# 4G with a smaller tree, and the client keeping four data streams open
irsync-netstress --profile 4g-vehicle --direction push --max-total-size 64M ~/work/ns-4g -- --parallel 4
# Info-level logs (debug is the default, and is large on long runs)
irsync-netstress --profile 4g-vehicle --direction pull --log-level info ~/work/ns-4g-info
Profiles
Each profile describes one kind of bad network. “Up” is client to daemon, “down” is daemon to client. On a push the file data goes up; on a pull it comes down. A slow uplink therefore hurts pushes most.
4g-vehicle: a moving vehicle on 4G
| down (daemon to client) | up (client to daemon) | |
|---|---|---|
| speed | 2 to 30 Mbit/s | 0.7 to 10 Mbit/s |
| speed changes | a new speed every 2 to 6 s | same |
| queue | 512 KiB (about 2 s at the slowest speed) | 256 KiB (about 3 s at the slowest speed) |
| delay | 30 ms each way, drifting by up to ±20 ms | same |
| loss | about 1%, in bursts: normally 0.2%, but now and then the link goes bad and loses 20% for a while | same |
| other | 0.5% of packets arrive out of order, 0.1% arrive twice | same |
Outages, in both directions at once:
- Handovers every 30 to 90 s, each cutting the link for 0.2 to 2 s, like moving from one cell tower to the next. Too short to force a reconnect.
- One dead zone per sync, 20 to 60 s long, like a tunnel. It opens once the sync has moved 256 KiB to 4 MiB of traffic, so it always hits in the middle of a transfer. It is long enough that the client must give up on the connection, reconnect and resume.
Run defaults: 10 iterations, 100 filegen steps, trees up to 256M, files up
to 32M, client --idle-timeout 10.
What it is meant to catch: resume bugs, files left half-written, state that does not survive a reconnect, the client or daemon getting stuck or giving up.
dsl-video: a DSL line overloaded by video streaming
| down (daemon to client) | up (client to daemon) | |
|---|---|---|
| speed | 16 Mbit/s, fixed | 1 Mbit/s, fixed |
| queue | 1536 KiB | 64 KiB (about 0.5 s) |
| delay | 10 ms each way, drifting by up to ±2 ms | same |
| loss | 0.01% at random | same |
| video traffic | every 2 to 4 s a burst of 1 to 2 s: the video fills the queue to 1280 KiB and then takes 10 of the 16 Mbit/s. irsync’s packets wait behind it (650 to 790 ms extra delay) and are lost only if irsync sends faster than the 6 Mbit/s left over. | none |
No handovers and no dead zones. The link never drops, so any reconnect fails the iteration: under this profile the client should never decide the connection is dead.
Run defaults: 10 iterations, 100 filegen steps, trees up to 32M, files up
to 4M, client --idle-timeout 10.
What it is meant to catch: timeouts that are too short for a slow or overloaded line, stalls when packets wait a long time in a queue, and irsync giving up on a peer that is merely slow.
long-rtt: a long, clean line
| down (daemon to client) | up (client to daemon) | |
|---|---|---|
| speed | 50 Mbit/s, fixed | 10 Mbit/s, fixed |
| queue | 1024 KiB | 256 KiB |
| delay | 45 ms each way (90 ms round trip), no drift | same |
| loss | none | none |
No reordering, no cross traffic, no outages, so any reconnect fails the
iteration. Run defaults: 5 iterations, 2000 filegen steps, trees up to 64M,
files up to 64K, client --idle-timeout 10. The many small files mean many
round trips.
What it is meant to show: how irsync behaves when every round trip takes a
long time, and settings that only matter then, such as --acks.
test-blackout: for the rig’s own tests
No speed limit, no delay, no loss. One 6 s dead zone per sync, after 256
KiB of traffic. Client --idle-timeout 2. Defaults: 3 iterations, 50 steps,
trees up to 8M, files up to 1M.
It exists so the automated tests can check the reconnect path in seconds. It is also a quick way to check that a build and a machine work before starting a long real run. It does not simulate any real network; don’t use it for campaigns.
test-slow: for irsync’s own tests
A clean 256 kbit/s uplink with a 64 KiB queue, an unlimited downlink, no
loss, no delay, no outages. irsync’s test
a_slow_uplink_that_needs_more_than_a_minute_still_delivers_everything
(in crates/irsync/tests/netsim.rs) uses it to push data that takes over
a minute of network time, on tokio’s paused clock. irsync-netstress does not offer it.
test-dead-zones: for irsync’s own tests
The test-slow link with a 6 s dead zone every 512 KiB of traffic, again
and again. irsync’s test
a_big_push_through_repeated_dead_zones_keeps_going_while_data_moves (in
crates/irsync/tests/netsim.rs) uses it to push one 8 MiB file that no
single connection can finish, and checks that the client keeps redialling
while each connection moves part of it. A connection carries less than the
file’s largest chunk, so that chunk arrives over several connections. irsync-netstress does not offer it.
test-wan: for measurements
A fast, clean long-distance link: 100 Mbit/s each way, 40 ms of delay in
each direction (80 ms round trip), a 2 MiB queue, no loss, no outages. It
was added to measure how --parallel bounds files per round trip (see
docs/IRSYNC_DECISIONS.md, 2.1 item 7); set IRSYNC_NETSIM by hand, as for
test-slow. irsync-netstress does not offer it.
Where the numbers come from
The numbers are a first proposal based on what these networks are known to
do, not measurements. The exact values are in two places:
crates/irsync/src/net/netsim/profile.rs (the link and the outages) and
crates/netstress/src/profile.rs (run sizes and client timeout). See
Changing or adding a profile.
What a run does
The sequence is irsync-stress’s, with the fault layer switched on:
- Checks the tools. Finds
irsync,filegenandfileset, and refuses to go on unlessirsync --versionends with[netsim]. Only then does it create the root. - Writes
run.tomlwith every setting, so the run can be repeated. - Starts the daemon with
IRSYNC_NETSIMset for the daemon side. It waits up to 15 s for the daemon to lognetsim active, which proves the fault layer really is on. - Ping round. One sync of a single small file, which must arrive byte for byte. This proves the two sides can talk through the fault layer before any real work. A failure here is a setup failure (exit 2).
- Fills the source tree with filegen and records its manifest with
fileset init. - For each iteration:
- Checks the daemon is still running and writes
=== iteration N ===into the daemon log. - Runs the client with
IRSYNC_NETSIMset for the client side. Each iteration gets its own fault schedule (its own speeds, losses and dead zone timing). - Checks the daemon survived the sync.
- Reads the client log: was the fault layer active, did each dead zone end in a resumed session, was there any reconnect outside a dead zone?
- Compares the two manifests and runs
fileset checkon the destination, as irsync-stress does. - Prints the iteration line. Then mutates the source tree with filegen for the next round.
- Checks the daemon is still running and writes
- Stops the daemon, looks for
.irsync.*.partfiles left anywhere in either tree, prints the footer and exits.
On a push the client’s tree is the source and the daemon’s export is the destination. On a pull they swap.
What counts as a pass
An iteration passes when everything irsync-stress checks passes:
- the client exits 0,
- the source and destination manifests match,
fileset checkfinds no differences,
and the network side looks right too:
- the client log says
netsim active(the fault layer was on), - every dead zone that opened was followed by the same session
resuming (
session started ... resumed=truewith the first session’s id), - there was no reconnect outside a dead zone,
- the daemon is still running afterwards.
Across the whole run:
- no
.irsync.*.partfile is left in either tree, - if the profile has dead zones, at least one sync must actually have hit one. Otherwise nothing was tested (exit 3).
A single sync that ends before its dead zone is due (because it moved less
than the threshold) is noted with outages 0, not failed. Later
iterations of a run often move little data, so this is normal for them.
Output
A header, one line per iteration, a footer:
irsync-netstress
root: ~/work/ns-4g-push
seed: 1
direction: push
endpoint: 716a53cc4cea6705494da4d3b72cae40cfa658440e2e1fe4afba1f1bfbc2a5bb
address: 127.0.0.1:50357
network: 4g-vehicle
iter 0001/0010 sync 94.7s exit 0 manifest ok check ok outages 1
iter 0002/0010 sync 61.2s exit 0 manifest ok check ok outages 1
...
passed=10 failed=0 elapsed=812.3s outages=10
sync: how long the client took. Under4g-vehiclethis includes the dead zone, so 60 to 160 s is normal.exit: the client’s exit code. 0 is success, 23 means some files did not transfer.outages: how many dead zones opened during this sync (0 or 1).- The footer’s
outages=is the total for the run.
A failed iteration gets an extra line under it when the network checks failed, naming the reason and the client log:
iter 0001/0010 sync 72.3s exit 0 manifest ok check ok outages 0
reconnect without a dead zone (1 time(s)); see ~/work/ns-dsl/logs/iter-0001.client.log
When the file checks failed, the path of the check report follows instead, as in irsync-stress:
iter 0003/0010 sync 104.2s exit 23 manifest MISMATCH check FAILED (added=1 deleted=1 changed=0) outages 1
~/work/ns-4g-push/logs/iter-0003.check.txt
At the end, any partial files left behind are listed before the footer:
partial file left behind: ~/work/ns-4g-push/DST/data/a/b/.irsync.report.pdf.part
and a run where no dead zone ever opened ends with:
faults did not bite: no iteration had an outage
The possible reasons on the extra line:
| Reason | Meaning |
|---|---|
fault layer not active | The client log has no netsim active line. |
reconnect without a dead zone (N time(s)) | The client decided the connection was dead and reconnected while the link was up (no dead zone open). The link was slow or lossy, but not down. |
dead zone did not end in a resumed session (D dead zone(s), R resumed) | A dead zone opened, but afterwards the client did not resume the session it had before: it started a fresh one, never got back, or the sync ended. |
Exit codes
| Code | Meaning |
|---|---|
0 | Every iteration passed. |
1 | At least one iteration failed (file checks or network checks), or a partial file was left behind. |
2 | The rig could not do its job: bad arguments, a root that is not empty, a missing tool, an irsync without the fault layer, the daemon did not start or died, the ping round failed, a tool failed, or the client exited with something other than 0 or 23. |
3 | The profile has dead zones but none opened in the whole run, so the reconnect path was never tested. This is not a pass. Usually the trees were too small; raise --max-total-size. |
4 | --concurrent only: no file changed during a sync was ever placed, so the run tested nothing. |
130 | Interrupted (Ctrl-C or SIGTERM). The daemon and any running client are stopped first. |
Files a run leaves behind
The layout is irsync-stress’s:
ROOT/
run.toml every setting of the run, enough to repeat it
SRC/config/, SRC/data/ the source side (the client on a push)
DST/config/, DST/data/ the destination side (the daemon on a push)
filegen/ filegen's log and state
logs/
daemon.log the daemon's log for the whole run, with === iteration N === markers
ping.client.log the client log of the ping round
filegen.stderr.log filegen's error output
iter-0001.client.log the client log of each iteration
iter-0001.check.txt what fileset check found
iter-0001.manifest.blake3 hashes of both manifests
run.toml has one extra section:
[network]
profile = "4g-vehicle"
client_timeout_secs = 10
reconnect = "5m"
The logs are small (a few MB for a 10-iteration 4G run at debug); the
data trees are what take space, up to the profile’s total size on each
side. Delete roots you no longer need. The sweep script deletes the roots
of passing runs for you.
Known limits
- Not a packet-for-packet replay. See Repeating a run.
- CPU-sensitive. The simulation runs in the irsync processes on the real clock. A busy machine delays packets on top of the simulated delay. Real runs are best done alone, or a few at a time.
- Loopback only, IPv4 only. Both sides run on this machine.
- Only the client has outages. The client’s fault layer drops both what it sends and what it receives during a handover or dead zone; the daemon’s never cuts the link itself. Both directions are still cut.
- One dead zone per client process. A sync is one client process, so one per sync. A sync that moves less than the threshold gets none.
- First-proposal numbers. The profiles have not been checked against measured networks.
- Client kill and daemon crash are not covered. The rig neither kills the client mid-sync nor crashes the daemon.
How netstress works
Part of Testing: how the netstress rig works inside.
This page explains what happens inside the network-fault rig: how the fault layer gets between irsync and the network, how it decides what happens to each packet, and how the rig decides whether a run passed. For how to use it, see Network stress with netstress. The decisions made while building it and the first results are in NETSTRESS_DECISIONS.md.
The big picture
There are two parts:
- The fault layer, inside irsync itself. It is compiled in only with
the cargo feature
netsim, and switched on at run time by theIRSYNC_NETSIMenvironment variable. When it is on, every QUIC packet irsync sends or receives passes through a simulated link. - The rig,
irsync-netstress. It is irsync-stress’s loop (make a tree, sync it, check it, change it, repeat) with the variable set on the daemon and on every client, plus checks that read the client logs to make sure the network did what it should.
irsync-netstress
(filegen, fileset, run.toml, logs, checks)
| |
spawns once, with spawns once per iteration, with
IRSYNC_NETSIM=...,side=daemon IRSYNC_NETSIM=...,side=client,stream=<i>
| |
v v
+-------------------------+ +-------------------------+
| irsync daemon | | irsync client |
| session, files | | session, files |
| iroh endpoint, QUIC | | iroh endpoint, QUIC |
| +-------------------+ | | +-------------------+ |
| | netsim transport | | | | netsim transport | |
| | downlink model | | | | uplink model | |
| | | | | | handovers, | |
| | | | | | dead zone | |
| +---------+---------+ | | +---------+---------+ |
+-------------|-----------+ +-----------|-------------+
| real UDP sockets on 127.0.0.1 |
+---------------------------------------------+
Both programs are the real irsync binaries, running as separate processes on this machine, exactly as in irsync-stress. Only the network between them is simulated, and it is simulated in real time: a 1 Mbit/s uplink really carries 1 Mbit/s.
Why a custom transport
iroh, the networking library irsync uses, lets a program add its own “custom transport”: a piece of code that carries iroh’s packets instead of an ordinary UDP socket. The fault layer is such a transport. It still uses a real UDP socket on 127.0.0.1 underneath, but it decides for every packet whether, when and how often it gets sent.
The alternatives, and why they were not used:
- A proxy between client and daemon: ruled out in the design.
- The operating system’s traffic shaping (
pfand dummynet on macOS,tc netemon Linux): needs root, and differs per system. - turmoil or another whole-program simulator: needs both peers in one process on a simulated clock with simulated sockets. irsync talks through iroh and its QUIC stack with their own sockets, and does real, blocking disk I/O that a simulated clock does not cover.
The custom transport needs only a few hooks in irsync, works without root
on macOS and Linux, and keeps the real binaries and the real clock. Its
cost: iroh marks the hook as unstable, so an iroh upgrade may break it.
Because all of it is behind the netsim feature, such a break shows up
only as a failure to build the fault build, never in a normal build.
How irsync is wired to the fault layer
Everything sits behind #[cfg(feature = "netsim")]. A normal build has
none of this code and never reads the variable.
- The feature (
crates/irsync/Cargo.toml) turns on iroh’sunstable-custom-transportsand a few small dependencies the transport needs (iroh-base,n0-watcher,noq-udp,rand,rand_chacha). - The version (
crates/irsync/src/build_info.rs): a fault build’sirsync --versionends with[netsim]. The rig and the sweep script check this before doing anything. - Reading the variable (
netsim::active()incrates/irsync/src/net/netsim/mod.rs): read once per process and remembered. Unset means off. A value that does not parse is an error every time it is asked for, so irsync stops instead of silently running without faults. - Building the endpoint (
build_endpointincrates/irsync/src/net/endpoint.rs): when the variable is set, irsync logsnetsim activeatwarn, removes iroh’s ordinary IP transport and its relay transport, and adds the fault transport. With the ordinary paths removed, iroh has no way to reach the peer except through the fault layer. A test (crates/irsync/tests/netsim_endpoint.rs) checks that such an endpoint offers no IP or relay address. The transport binds to the first IPv4 bind address irsync was given, or127.0.0.1on a free port. - The daemon’s address (
listen_addrsincrates/irsync/src/daemon.rs): the daemon prints the fault transport’s socket address in its startup lines, so the rig (or a person) knows where to point the client. - The client’s dial (
dial_addrsincrates/irsync/src/client/connect.rs): the client turns each address it would dial into a fault-transport address. IPv6 addresses are refused.
A fault-transport address is the IPv4 address’s 4 bytes followed by the
port’s 2 bytes, tagged with the transport id 0x6e65_7473_696d (“netsim”
in ASCII).
Each irsync process builds its endpoint once. A client reconnecting after a dead zone reuses the same endpoint, so the same fault transport, with the same link and outage state, carries the whole sync.
The path of one packet
Each side simulates only its own outgoing direction: the client’s transport is the uplink (client to daemon), the daemon’s transport is the downlink (daemon to client). So every packet is shaped exactly once, by the side that sends it.
Outages are simulated only on the client, but in both directions: the client’s transport drops what it sends and what it receives while a handover or the dead zone is on. That cuts the whole link without the two processes having to agree on timing.
Sending (Shared::send in transport.rs):
iroh hands over a transmit (one packet, or several packed together)
|
split into individual packets
|
for each packet:
count it as sent
client only: is the link up (no handover, no dead zone)? no -> drop (outage_drops)
link model: queue full? yes -> drop (queue_drops)
link model: lost? yes -> drop (loss_drops)
link model: when does it arrive? (once, or twice if duplicated)
put it on the delivery queue with that time
The send call always tells iroh “done” at once. The fault layer never makes iroh wait; a packet that does not fit is dropped, as on a real link.
Delivering (deliver in transport.rs): a background task keeps the
waiting packets sorted by delivery time. When a packet’s time comes, it
sends it on the real UDP socket to the peer. Loopback adds almost nothing,
so the packet arrives when the model said it would, to within the tokio
timer’s resolution of about 1 ms. On a fast link several packets fall into
the same millisecond and arrive together, so the receiver sends fewer ACKs
than it would on a real link where they come one at a time. Measurements
of ACK traffic undercount for this reason.
Receiving (poll_recv in transport.rs):
read a packet from the real socket
|
bigger than iroh's buffer? yes -> drop (truncated)
client only: is the link up? no -> drop (outage_drops)
hand it to iroh
To spot packets that are too big, the transport reads into a buffer one byte larger than iroh’s; if that extra byte gets filled, the packet would have been cut short, so it is dropped and counted instead.
The link model
Link in crates/irsync/src/net/netsim/link.rs decides each packet’s
fate. It has no clock of its own: it is told the current time with each
packet. That keeps it simple to test: the same seed and the same packets
at the same times always get the same fates.
The parameters per profile and direction are in
crates/irsync/src/net/netsim/profile.rs (LinkParams). For each packet
the model does the following, in this order.
1. The queue
The link has a speed and a queue in front of it, like a router’s buffer in front of a slow line. The model treats the queue as an amount of bytes, not a list of packets:
- Between packets, the queue drains at the link’s speed.
- A new packet is added to the queue. If that would make the queue bigger
than its limit (
queue_bytes), the packet is dropped. - Otherwise its waiting time is the bytes now in the queue (its own included) divided by the link’s speed.
So a sender that sends faster than the link sees its packets wait longer and longer, and then get dropped once the queue is full. That is “bufferbloat”, and it is what QUIC’s congestion control has to cope with.
A queue of u64::MAX (as in test-blackout) means no queue at all: no
waiting, no queue drops.
2. Speed changes
When a profile gives a range of speeds (4G: 2 to 30 Mbit/s down), the model draws a new speed at random within that range every so often (4G: every 2 to 6 s). The queue drains at the old speed up to the moment of the change, then at the new one. A fixed speed (DSL) never changes.
3. Cross traffic (video)
dsl-video’s downlink shares its queue with someone else’s video stream.
The video comes in bursts: every 2 to 4 s a burst starts and lasts 1 to
2 s. During a burst:
- While the queue holds less than
hold_bytes(1280 KiB), the video pours in at twice the link speed (load= 2.0), so the queue fills at the link speed. - Once the queue reaches
hold_bytes, the video holds it there, like a real video player that backs off once its own traffic starts to queue. It takes 10 of the 16 Mbit/s (share= 0.625). Whatever irsync has added above that level drains at the 6 Mbit/s that is left.
Only irsync’s packets can fill the last 256 KiB of the queue. So irsync loses packets only if it sends faster than its 6 Mbit/s share for long enough to fill that space, not just because the video is playing. Its packets do wait behind the video: 1280 KiB at 16 Mbit/s is about 650 ms of extra delay.
Between bursts the queue drains at the full link speed.
A video that filled the queue completely would drop every irsync packet for up to about a second in every burst: a total blackout, not an overloaded line. See call 12 in NETSTRESS_DECISIONS.md.
4. Bursty loss
Real wireless links lose packets in clumps, not evenly. The model uses the standard two-state “Gilbert-Elliott” approach: the link is either in a good or a bad state, and each state has its own loss rate.
For each packet that got into the queue, the model first decides whether the state changes, then whether this packet is lost:
| 4G value | meaning | |
|---|---|---|
to_bad | 0.004 | chance per packet that a good link turns bad |
to_good | 0.1 | chance per packet that a bad link recovers |
loss_good | 0.002 | loss while good (0.2%) |
loss_bad | 0.2 | loss while bad (20%) |
With these numbers a good spell lasts about 250 packets and a bad spell
about 10, the link is bad about 4% of the time, and about 1% of packets
are lost overall, many of them close together. dsl-video never goes bad
and loses 0.01% at random.
A lost packet has already taken its place in the queue, as if it were lost on the wire after the bottleneck.
5. Delay, jitter, reordering, duplicates
- Delay: every packet gets the fixed one-way delay (
base_delay_ms) on top of its queueing time. - Jitter: an offset that drifts slowly, up to
jitter_mseither way. Every 100 ms it takes a random step of up to a quarter of that amount. So delay changes smoothly over time instead of jumping per packet. - Order: jitter alone never changes the order of packets. A packet never arrives before the one sent just before it.
- Reordering: a small share of packets (4G: 0.5%) gets 5 to 30 ms extra and may arrive after packets sent later.
- Duplicates: a small share (4G: 0.1%) is delivered twice, the second copy 1 ms after the first.
Handovers and dead zones
Outages in crates/irsync/src/net/netsim/outage.rs decides when the
link is down. It exists only on the client. It is asked for every packet
the client sends or receives, and answers “up”, “handover” or “dead zone”.
Handovers run on a timetable: the first starts 30 to 90 s after the
transport starts, each lasts 0.2 to 2 s, and the next one starts 30 to
90 s after the previous one started. They are short on purpose: shorter
than the client’s 10 s --idle-timeout, so QUIC simply resends what was lost
and the sync carries on. A handover that would start during the dead zone
is skipped.
The dead zone is triggered by traffic, not time. The model counts the bytes of every packet passing the client, in both directions. When the count reaches a threshold drawn at the start (4G: somewhere between 256 KiB and 4 MiB), the dead zone opens and lasts its drawn length (4G: 20 to 60 s). It happens once per client process, so once per sync.
Counting traffic instead of time means the dead zone always lands while data is moving, whether the link is fast or slow, and never while the client is still starting up or after it has finished. The cost: a sync that moves less than the threshold never gets a dead zone. The rig notes that and only complains if no sync of the whole run got one.
The client logs netsim: dead zone open secs=N when it opens. It notices
the end on the first packet after the end time and then logs
netsim: dead zone closed. Since the client keeps trying to reconnect
during the dead zone, there is a packet soon after the end.
Time
Both models get their time handed to them: the time since the transport was created, from tokio’s clock. This has two effects:
- The models can be tested without waiting. The unit tests feed them thousands of packets at made-up times and check the results (for example: 4G loses between 0.4% and 2% of packets, and some losses come in a row).
- A real run depends on real timing. Which packet arrives during a dead zone, or finds the queue full, depends on when irsync sends it, which depends on CPU load and thread scheduling. That is why a seed does not replay a run packet for packet.
The daemon is one process for the whole run, so its downlink model runs for the whole run too. Its speed changes and video bursts carry on across iterations, including the time between them. Each client is a new process with a fresh uplink model and a fresh outage model.
Seeds and streams
All random choices come from seeded generators (ChaCha8), one per model: one for the link and, on the client, one for the outages. Each generator’s seed is made from four things:
- the run’s seed (
--seed), - the side (client or daemon),
- the stream number,
- the purpose (link or outages).
fault_seed in crates/irsync/src/net/netsim/mod.rs mixes these one
after another with splitmix64, a standard way to scramble a number so that
inputs that differ in any part give unrelated outputs.
The rig numbers streams like this:
| Process | side | stream |
|---|---|---|
| the daemon | daemon | 0 |
| the ping round’s client | client | 0 |
| iteration i’s client | client | i |
So each iteration has its own fault schedule, and that schedule does not depend on how many iterations ran before it: iteration 5 of seed 3 gets the same draws whether the run has 5 iterations or 50. A test checks that 10 seeds times 10 streams give 100 different seeds for each purpose. Simpler mixing makes many schedules come out the same; see call 5 in NETSTRESS_DECISIONS.md.
What irsync does during a dead zone
The rig gives the client --idle-timeout 10 (under the real profiles) and
--reconnect 5m. A typical 4G dead zone of, say, 40 s then goes like this:
0 s dead zone opens. Every packet in both directions is dropped.
QUIC resends and sends keep-alives (every 5 s); all are dropped.
10 s client: "no activity; dropping the connection secs=10"
client: "session failed", "connection lost; reconnecting"
The client keeps trying to connect again, inside its 5 minute window.
40 s dead zone ends. The next connection attempt gets through.
client: "netsim: dead zone closed"
client: "session started session=<same id> resumed=true"
The sync carries on where it stopped; partly sent files are resumed.
The daemon notices the old connection is gone (it logs
connection failed: control stream: connection lost) and accepts the new
one. Its QUIC idle timeout is 60 s.
Why the numbers fit together:
--idle-timeout 10is longer than the longest handover (2 s), so a handover never forces a reconnect, and shorter than the shortest dead zone (20 s), so a dead zone always does.--reconnect 5mis far longer than the longest dead zone (60 s), so the client never gives up because of the dead zone itself.
The sender waits for the receiver to confirm each piece of a file it sent, with no time limit of its own: on a slow link, many pieces share the line and confirmation can take minutes. A fixed limit there fails healthy pushes over slow uplinks, as the first sweeps in NETSTRESS_DECISIONS.md show. A dead peer still ends the wait, through a lost connection.
How the rig judges a run
On top of irsync-stress’s checks (client exit, manifests, fileset check), the rig reads each iteration’s client log (netlog.rs in
crates/netstress/src). It removes the colour codes, then walks the
lines in order:
netsim active: the fault layer was on.netsim: dead zone open: count a dead zone; from here until the nextsession started, the client is “in a dead zone”.connection lost; reconnectingoutside a dead zone: count a stray reconnect. Inside a dead zone, reconnects are expected and not counted.session started: note itssession=id (the first one is the sync’s session) and itsresumed=value. If it comes after a dead zone, saysresumed=trueand has the first session’s id, count the dead zone as resumed. Either way, the dead zone part is over.
The session started line also carries a session_id= and a resumed=
in its prefix (from the logging context), which can differ from the
event’s own values after a reconnect. The parser only reads what comes
after the words session started.
The iteration then fails with a reason when:
netsim activeis missing, or- there was any stray reconnect, or
- more dead zones opened than were resumed.
Exit codes for the whole run (report.rs):
- 1 if any iteration failed, or a
.irsync.*.partfile was found anywhere in either tree after the daemon stopped; - otherwise 3 if the profile has dead zones but no iteration logged one;
- otherwise 0.
Exit 2 comes from anything that stops the rig before it can judge: a
missing or non-fault irsync, a daemon that does not log netsim active
within 15 s or dies, a failed ping round, or a client exit other than 0
or 23.
The counts
Each transport counts what happens to its packets and logs it at warn
every 10 s while traffic flows and once when the transport is dropped:
netsim: counts sent=4814 queue_drops=0 loss_drops=0 outage_drops=0 send_errors=0 truncated=0
The rig does not judge these; they are there for a person reading a failure. They answer “did the network do what the profile says, or something else?”. For example, losses far above what the profile should give point at the fault layer; a stall with no drops at all points at irsync. The meaning of each count is in the user guide.
The final line is best effort: a process that exits without closing its endpoint, like the daemon when the rig stops it, skips it, and its last 10-second line is the latest one.
Simplifications
Things the model does not do, on purpose or for now:
- The queue is a byte count, not a list of packets. Waiting time is the bytes in the queue divided by the full link speed. While the video holds the queue, irsync’s bytes above the video’s level actually drain at irsync’s 6 Mbit/s share, so the model’s delay for them is a little lower than a strict model would give.
- Each side shapes only what it sends, and the two directions are independent. Real links sometimes couple them (a busy downlink delaying uplink acknowledgements); this model does not.
- The daemon’s downlink is one link for the whole run, shared by whichever client is connected. Only one client runs at a time, so this does not matter for the rig.
- Outages are only on the client. The daemon’s transport never cuts the link; the client’s drops both directions.
- No NAT, relays, address changes or path changes. The fault layer only decides what happens to packets on one path between two fixed addresses.
- IPv4 and loopback only.
Where the code is
| Code | What it does |
|---|---|
crates/irsync/src/net/netsim/mod.rs | The variable, profile names, seeds (fault_seed), the address format, netsim active. |
crates/irsync/src/net/netsim/profile.rs | The numbers of every profile. |
crates/irsync/src/net/netsim/link.rs | The link model: queue, speed, video, loss, delay. |
crates/irsync/src/net/netsim/outage.rs | Handovers and the dead zone. |
crates/irsync/src/net/netsim/transport.rs | The iroh custom transport: sending, delivering, receiving, counts. |
crates/irsync/src/net/endpoint.rs, daemon.rs, client/connect.rs, build_info.rs | The hooks into irsync. |
crates/netstress/src/run.rs | The rig’s run: tools check, daemon, ping, iterations, partial files. |
crates/netstress/src/netlog.rs | Reading a client log for the network story. |
crates/netstress/src/report.rs | Header, iteration lines, footer, exit codes. |
crates/netstress/src/profile.rs | Run defaults and client timeout per profile. |
crates/netstress/src/cli.rs, run_file.rs | Command line and run.toml. |
crates/netstress/tools/sweep.sh | Many runs at once. |
crates/stress | The loop, layout, daemon handling and checks the rig reuses. |
Trace and capture the protocol
Four ways to watch irsync talk, from the simplest to the most detailed:
- The text trace prints every protocol message to the log, one line
each. Use it to read a session as it runs, or to
grepa log. - The capture file writes every message to a file that Wireshark opens. Use it to browse a session, filter it, and see the streams side by side.
- The byte count reads a capture file and says what each message and field cost in bytes. Use it to see where a session’s bytes go.
- The key log lets Wireshark decrypt a capture of the real QUIC packets. Use it to see what happens below irsync: packets, loss, retransmits, flow control.
The trace, the capture and the byte count see irsync’s messages, after QUIC has decrypted and ordered them. They work on any connection: direct, through a relay, and in the in-process network tests. The key log works on the raw packets, and only on a direct connection. Networking explains the layers, and walks through a traced push.
The text trace
Give -vvvvv to either side:
irsync -avvvvv ~/Photos/ myserver:photos/
irsync daemon -vvvvv
Or name the trace’s log target, irsync::wire, in RUST_LOG, which works at
any verbosity and overrides -v:
RUST_LOG=info,irsync::wire=trace irsync -av ~/Photos/ myserver:photos/
irsync::wire sits under irsync, so RUST_LOG=irsync=trace turns the
trace on too. To get irsync’s trace logs without it, add ,irsync::wire=off:
RUST_LOG=irsync=trace,irsync::wire=off irsync -av ~/Photos/ myserver:photos/
The trace goes to stderr with the other logs, at trace level. Each message sent or received is one line. A line from a push, as the client logged it:
2026-11-14T14:49:35.753947Z TRACE session{direction=ClientSends side="client" role="sender" peer=5d0afa5896 source_index=0 session_id="88f83bf99415409cb371c2144a9d1123" resumed=false}: irsync::wire: Control { need: NeedChunks { file_id: 1, chunk_idx: [0] } } side="SIDE_CLIENT" dir="DIRECTION_RECEIVED" stream="STREAM_KIND_CONTROL" quic_stream=0 conn=1 session=88f83bf99415409cb371c2144a9d1123 file=1
Before irsync::wire: is the usual log prefix: the time and the session’s
log span. Then comes the message, in full, and these fields:
| Field | Meaning |
|---|---|
side | Who logged it: SIDE_CLIENT or SIDE_DAEMON. |
dir | DIRECTION_SENT or DIRECTION_RECEIVED, from that side’s point of view. DIRECTION_UNSPECIFIED for a stream being opened and for a path change. |
stream | STREAM_KIND_CONTROL, STREAM_KIND_LISTING or STREAM_KIND_DATA; see Protocol. |
quic_stream | The QUIC stream id. |
conn | The connection’s number in this process, from 1. A reconnect gets a new one. |
session | The session id in hex, - until the HelloAck. |
file | The file id the message or the data stream is about, - if none. |
The message prints field by field. Fields at their default value (0, empty,
false, the first enum value) are left out. Hashes print in hex, paths as
text when they are valid UTF-8. File content never prints: a DataChunk’s
data and the literal bytes in a delta print as their length and the first 8
bytes of their BLAKE3 hash:
DataChunk { data: <12 bytes, blake3 07c6fb3c62e3e041> }
Two more kinds of line are not messages but events: StreamEvent when a
stream is opened, finished or reset (with the error), and PathChange when
iroh moves the connection to another path, such as from the relay to a
direct address.
To follow one file, grep for its id, with the space after it:
grep 'irsync::wire' client.log | grep 'file=12 '
The capture file
Set IRSYNC_CAPTURE to a file name, on the client, the daemon or both:
IRSYNC_CAPTURE=~/push.pcapng irsync -av ~/Photos/ myserver:photos/
IRSYNC_CAPTURE=~/daemon.pcapng irsync daemon
irsync logs a warning naming the file: writing a protocol capture to FILE; it holds paths and file names. The file is pcapng, the format Wireshark saves in. An existing file is
overwritten. A daemon writes every session it serves into the one file.
Before it exits, irsync waits up to 2 seconds for the last records to reach
the disk. If another process is already writing the file, the second one
writes <stem>.<pid>.pcapng next to it instead, where <stem> is the name
without its extension: for ~/push.pcapng, that is ~/push.<pid>.pcapng.
The warning names that file. When a test runs the client and the daemon in
one process, both write into the same file, so each message is there twice:
once sent, once received.
What is in it
Each packet holds one irsync.capture.v1.Record, a protobuf message that
exists only in the capture and is never sent. It is defined in
proto/irsync/capture/v1/record.proto. It holds:
- the irsync message exactly as sent or received, in the
msgfield, or a stream event or a path change instead; - where it was seen:
side,direction,stream,quic_stream_id,session_id,file_idandconnection, as in the trace; local_endpoint_idandremote_endpoint_id, the two keys;encoded_len, the message’s size on the wire, without the length prefix;trimmed, when something was cut out (below).
Each packet’s timestamp is the time irsync wrote or read the message. Under the network tests’ simulated clock it is simulated time.
Trimming
Two things are cut so that a capture is safe to look at and Wireshark can read it:
- File content is never written. A
DataChunkkeeps everything except its data and the literal bytes of its delta. For each piece removed,trimmed.contentholds its length and the first 8 bytes of its BLAKE3 hash. - Wireshark refuses a packet over 256 KiB. A larger message, such as a
long
ChunkListStart,ChunkListMoreorNeedChunks, keeps its first entries up to that size.trimmed.original_lengives its full size andtrimmed.dropped_entrieshow many entries were dropped.
The text trace always shows the whole message, apart from file content.
Admin sessions (irsync remote) are traced and captured too: their
AdminRequest and AdminReply messages appear like the others. A
capture of an admin session holds the config contents it carries (export
paths, client names and ids), and no secrets.
Addresses and ports
The packets carry made-up addresses and ports, so that Wireshark’s conversation and flow views keep connections and streams apart:
- The daemon is always
fd69:7273::1:0:0. - The client end of each connection is
fd69:7273::<n>, wherenis the connection’s number in the file, counted from 1. A client that reconnects shows up as a new address; the record’ssession_idties its connections together. - Each QUIC stream gets the same port on both ends: its stream id plus 1, wrapping past 65,535. The control stream, QUIC stream 0, is port 1; the listing stream, 4, is port 5; the first data streams of a push, 2 and 6, are ports 3 and 7.
The real path, an IP address and port or a relay URL, is in the
PathChange records.
Open it in Wireshark
From your clone:
tools/wireshark/open-capture.sh ~/push.pcapng
The script starts Wireshark with two settings, nothing saved: decode every
packet as irsync.capture.v1.Record, and load the .proto files from
proto/. Wireshark’s own protobuf decoder does the rest; no plugin is
needed. To keep the settings, import the profile in tools/wireshark/profile/;
tools/wireshark/README.md
says how, and gives the same two settings for tshark.
The decoding and the flow graph below were checked with tshark 4.6. On
Ubuntu, tshark cannot read .proto files in your home directory and shows
every packet as <UNKNOWN>; tools/wireshark/README.md gives the
workaround. The Wireshark GUI is not affected.
In the packet details, each record opens up into its fields and the irsync message inside it. Some ways in:
- Filter. Wireshark can turn protobuf fields into display-filter fields,
so you can filter on a record’s session, file or stream kind. The names
follow the message’s full name, something like
pbf.irsync.capture.v1.Record.session_id, but check them in Wireshark: right-click the field in the packet details and pick Apply as Filter. If the fields aren’t offered, look under Preferences, Protocols, Protobuf for the option that dissects protobuf fields as Wireshark fields. - Flow graph. Statistics, Flow Graph draws the messages as arrows between the daemon and each client address, in time order, one column per address.
- Conversations. Statistics, Conversations lists each connection (an address pair) and each stream (a port pair) with its message count and bytes.
Count the bytes
The capture shows what each message holds. pbwalk shows what each part of
it costs. It reads a capture file and lists every protobuf field of every
message with its size in bytes, then adds up the totals: per message type,
per field, and per kind of overhead. Use it to see where the bytes of a
session go, or to check what a protocol change saves.
It counts irsync’s messages as they are on the wire, with their length
prefixes. It leaves out what QUIC, TLS and UDP add below that. So its
totals come out smaller than the sent … bytes received … bytes line
irsync prints at the end of a run with -v or --stats, which counts
the UDP bytes of the connection. File content
is not in a capture, but its size is still counted: pbwalk takes it from
the record’s encoded_len and trimmed fields, and prints it as cut.
It needs only the clone:
cargo run -p pbwalk -- ~/push.pcapng
First comes a listing, one block per message. This is a Hello, with its
last fields cut for space, from a capture of a small push:
#3 0.000232 fd69:7273::1 → fd69:7273::1:0:0 port 1 Hello 67 B + 1 B prefix
side=SIDE_CLIENT(1) direction=DIRECTION_SENT(1) stream=STREAM_KIND_CONTROL(1) connection=1 local_endpoint_id=7e5c34797aa6620e… remote_endpoint_id=a63aa632caa1d647…
protocol_version = 8 2 B (tag 1, value 1)
build: BuildInfo 27 B (tag 1, len 1, value 25)
version = "0.1.0-beta.6" 14 B (tag 1, len 1, value 12)
...
push: SyncRequest 38 B (tag 1, len 1, value 36)
path = "m" 3 B (tag 1, len 1, value 1)
contents_only = true 2 B (tag 1, value 1)
chunk_min = 65536 4 B (tag 1, value 3)
chunk_avg = 262144 4 B (tag 1, value 3)
chunk_max = 1048576 4 B (tag 1, value 3)
preserve: SyncRequest.Preserve 16 B (tag 1, len 1, value 14)
links = true 2 B (tag 1, value 1)
...
Each line is a field, its value, and its size. The size is the sum of its
tag (which holds the field number and the kind of value), its length (for
text, bytes and nested messages) and its value. In path = "m", the
tag takes 1 byte, the length 1 byte and the text 1 byte, so 3 B. A nested
message such as push counts its own tag and length as well as
everything inside it. The first line, after the message’s type, gives its
size on the wire: 67 B, plus 1 B for the length prefix in front of it.
Then come the totals. For the client’s side of a small push, shortened:
Totals: 53 messages and 13 events of 132 packets read; 901,180 B on the wire, length prefixes (86 B) included
By message
type count bytes share
DataChunk 15 900,060 B 99.9%
Control 25 588 B 0.1%
ListingFrame 7 242 B <0.1%
DataStreamHeader 3 72 B <0.1%
Hello 1 67 B <0.1%
HelloReply 1 47 B <0.1%
ListingStreamHeader 1 18 B <0.1%
total 53 901,094 B 100.0%
By field
path bytes share
DataChunk (cut content) 900,000 B 99.9%
Control.chunk_list_start.chunks.hash.bytes 102 B <0.1%
Control.chunk_list_start.whole_hash.bytes 102 B <0.1%
DataChunk (cut, not itemised) 60 B <0.1%
...
total 901,094 B 100.0%
Overhead
bytes share
not in the capture 900,060 B 99.9%
values 712 B 0.1%
tags 226 B <0.1%
length bytes 96 B <0.1%
length prefixes 86 B <0.1%
total 901,180 B 100.0%
Overhead splits the same bytes by what they are: the values themselves,
the tags, the length bytes, the length prefixes, and what the capture
does not hold.
By direction splits the messages into those sent and those received, as
seen by the side that wrote each one, length prefixes included. Its last
line is called sum, not total: in a file that both sides wrote, each
message is counted once sent and once received, so the sum can be twice
what went over the wire (see One side or both). Two
more rows appear only when they are not empty: unspecified for a record
without a direction, such as a stream being opened, and other for a
direction this build does not know.
Cut rows
A DataChunk in the listing shows what the capture left out:
#59 0.018612 fd69:7273::1 → fd69:7273::1:0:0 port 3 DataChunk 300,004 B + 3 B prefix
side=SIDE_CLIENT(1) direction=DIRECTION_SENT(1) stream=STREAM_KIND_DATA(3) quic_stream_id=2 session_id=b9db550af3b718a1335d80f16246cd08 file_id=3 connection=1 local_endpoint_id=628d53b962da7234… remote_endpoint_id=9af7fe23a076f62b…
cut content 300,000 B (1 piece)
cut, not itemised 4 B
Four rows can appear, and each is counted in the totals:
cut content: file content the capture never writes. The size is exact. A message that had content cut shows how many pieces.cut, not itemised: the rest of what the capture cut. It is the tag and length bytes of the cut fields. If a message was too big for Wireshark and entries were dropped, it also holds their size, and the row says how many were dropped.message not captured: the whole message is missing from the capture. Its full size is this one row.not in the capture, unexplained: bytes are missing and the record does not say why. This is not a cut. It can happen when a newer peer sent fields this build does not know.
One side or both
A capture written by a client or by a daemon holds each message once. A file that both wrote, as the tests do when they run client and daemon in one process, holds each message twice: once sent, once received. Its totals count every message twice. Pick one side:
cargo run -p pbwalk -- --where side=SIDE_CLIENT ~/push.pcapng
--where FIELD=VALUE keeps the records whose field of the capture’s
wrapper prints as that value. Give it more than once to narrow further.
The fields it takes are those on the second line of each message’s block:
side, direction, stream and so on. encoded_len,
trimmed and the message itself are not among them.
Pick messages
Each block starts with its message’s number, such as #120. To see only
that message, or a range of them:
cargo run -p pbwalk -- --message 120 ~/push.pcapng
cargo run -p pbwalk -- --message 100-120 ~/push.pcapng
--message-type keeps the messages of one type, as By message names
it:
cargo run -p pbwalk -- --message-type DataChunk ~/push.pcapng
Give either more than once to pick more. Note the difference from
--where: a second --where narrows, since a message must match both,
while a second --message or --message-type widens, since a message
matches one of them. The options combine with each other and with
--where: a message is shown only if every option picks it. A
message keeps its number, whatever else is left out. As with --where,
the totals then count only the messages picked.
More views
--group-by streamadds totals per stream kind (control, listing, data).--group-by side,streamadds one table per field, not one table of the two combined. It takes the same fields as--where.directionadds nothing, since the totals always have aBy directiontable.--top Nkeeps theNlargest rows ofBy message,By fieldand each--group-bytable, and folds the rest into one row, such as(97 more rows). The totals stay the same.By fieldlists about a hundred rows for a real push;--top 10shows where most bytes go.--totals-onlyskips the listing;--no-totalsskips the totals.- Long byte strings, long repeated fields and long header values are
shortened in the listing.
--fullprints them whole. -Cputs each field’s bytes in front of its line; see See the bytes.
The By stream totals of the same push:
By stream (with prefixes)
stream count bytes share
STREAM_KIND_DATA(3) 6 900,096 B 99.9%
STREAM_KIND_CONTROL(1) 27 701 B 0.1%
STREAM_KIND_LISTING(2) 8 323 B <0.1%
total 41 901,120 B 100.0%
See the bytes
-C, or --canonical-hex-dump, puts the bytes of each field in front of
its line: first in hex, 16 to a line, then the same bytes as characters,
with a . for every byte that is not a printable ASCII character. It is
the layout of hexdump -C without the offsets. A HelloReply:
cargo run -p pbwalk -- -C --no-totals ~/push.pcapng
#7 0.009716 fd69:7273::1:0:0 → fd69:7273::2 port 1 HelloReply 47 B + 1 B prefix
side=SIDE_DAEMON(2) direction=DIRECTION_SENT(1) stream=STREAM_KIND_CONTROL(1) …
12 2d |.-| ack: HelloAck 47 B (tag 1, len 1, value 45)
0a 10 32 22 75 f1 1f 4f c8 0f 25 0c 6f ec 85 03 |..2"u..O..%.o...| session_id = 322275f11f4fc80f250c6fec8503c5ee 18 B (tag 1, len 1, value 16)
c5 ee |..|
1a 19 |..| build: BuildInfo 27 B (tag 1, len 1, value 25)
0a 0c 30 2e 31 2e 30 2d 62 65 74 61 2e 36 |..0.1.0-beta.6| version = "0.1.0-beta.6" 14 B (tag 1, len 1, value 12)
12 07 38 37 32 65 38 65 33 |..872e8e3| commit = "872e8e3" 9 B (tag 1, len 1, value 7)
18 01 |..| dirty = true 2 B (tag 1, value 1)
A field with more than 16 bytes, such as session_id with its 18,
continues on the next line. A nested message such as ack or build shows only
its own two bytes, the tag and the length; the fields under it show the
rest. So no byte is printed twice and none is left out: the hex of one
block, read from top to bottom, is the message. Lines that stand for no
bytes in the file, such as a block’s first two lines and the cut content
row, leave both columns empty. --full changes the text only; the hex is
always complete.
The hex column is the first 48 characters of each line, so the bytes can be had back:
cargo run -p pbwalk -- -C --no-totals ~/push.pcapng | cut -c1-48 | xxd -r -p > messages.bin
That gives every message of the capture, one after the other; narrow it
with --where. Without --no-totals the command works the same: under
-C the totals are moved right as well, so nothing but hex is ever in
those 48 characters. -C cannot be combined with --totals-only.
Two things the hex is not:
- The message as it was on the wire, when the capture cut something. The bytes are those in the file. File content, and the entries dropped from a message over 256 KiB, are not there (see Trimming).
- The length prefix. It is not in the file;
pbwalkworks its size out. The hex of a block starts with the message’s first field.
With --no-unwrap, a block is the whole packet, and so is its hex.
Other protocols
pbwalk knows nothing of irsync except its default. --proto-path DIR
loads every .proto under DIR, and --type NAME says which message each
packet holds. --prefix none is for protocols without a length prefix.
A capture wraps each message in an envelope, and pbwalk unwraps it by
the numbering of the envelope’s fields:
- 1 to 19 are the wrapper’s own: where the message was seen,
encoded_lenandtrimmed. - 20 to 39 hold the message.
- 40 and up are events, such as a stream opening, which are listed but count as 0 bytes.
--no-unwrap skips that and walks each packet as --type from the top,
sizes being those of the bytes in the file. It cannot be combined with
--where or --group-by, which need the envelope unwrapped. The file
format and the envelope are in crates/pbcap.
Exit status
pbwalk exits with 0 when every message adds up, 1 when a message does not
(what is present, cut and missing does not equal its size on the wire) or
when it stops reading early, because the file is cut off or a block in it
is broken, and 2 when it cannot read the file or the protos. With status 1
it still prints its listing and totals, and says on stderr which problem
it found.
The key log
The trace and the capture show irsync’s messages. To see the QUIC packets underneath, capture the real traffic and give Wireshark the TLS secrets to decrypt it.
Set SSLKEYLOGFILE on the client or the daemon:
SSLKEYLOGFILE=~/irsync-keys.log irsync -av ~/Photos/ myserver:photos/
irsync logs a warning naming the file, writing TLS secrets to FILE (SSLKEYLOGFILE), and iroh logs one of its own. The secrets are added to the
end of the file, one block of lines per connection, in the key log format that
browsers also write (CLIENT_HANDSHAKE_TRAFFIC_SECRET …,
CLIENT_TRAFFIC_SECRET_0 … and so on). Either side’s file is enough, since
both ends of a connection share its secrets.
Capture the UDP packets at the same time, with Wireshark or tcpdump. For a
client and a daemon on one machine, with the daemon listening on port 43210:
sudo tcpdump -i lo -U -w /tmp/quic.pcap udp port 43210
tcpdump gives up root before it writes, so write to /tmp: the
tcpdump user cannot write to your home directory. Open the capture and
point Wireshark at the key log:
wireshark -o tls.keylog_file:"$HOME/irsync-keys.log" /tmp/quic.pcap
Wireshark finds the QUIC packets by itself. With the key log it decrypts the
handshake and the client’s packets: the frames inside each packet, the
acknowledgements, flow control limits and the stream frames. Follow, QUIC
Stream shows a stream’s bytes. On the control stream, stream 0, they start
with the first message’s length prefix and the Hello. Wireshark does not
decode the messages themselves, since it does not know irsync/1. The
capture file above is the way to read them.
What stays opaque:
- Frames Wireshark does not know. iroh’s QUIC library,
noq, speaks QUIC multipath (frames0x3e,0x3f,0x3e75to0x3e7c) and iroh’s own NAT traversal (frames0x3d7f90to0x3d7f94). Wireshark 4.6 knows neither. It cannot skip a frame it does not know, so it misreads the rest of that packet: expectUnknownframes with random-looking types and[Malformed Packet]ACKs after one of these. - Most packets from the server side. Each side hands out its connection
IDs in multipath
PATH_NEW_CONNECTION_IDframes, not the standard ones, so Wireshark cannot tie packets sent to those IDs to the connection. It marks them “Unknown QUIC connection” and does not decrypt them. In a checked push, the client’s packets on the main path all decrypted, and of the daemon’s, only the first two did; the rest were mostly acknowledgements. - Probes to other addresses. NAT traversal tries the other side’s other
local addresses too, so a capture on one interface can miss packets, and
one on
locan show packets between127.0.0.1and the machine’s LAN or Docker addresses. - Relayed traffic. Through a relay, the QUIC packets travel inside the relay connection’s own TLS, whose keys are not in the key log. Turn relays off, or dial an address (see Connect directly or through a relay), to get a direct connection.
Checked with tshark 4.6.4 and irsync 0.1.0-beta.1, client and daemon on one machine, dialled by address.
On Ubuntu, tshark (not the Wireshark GUI) reads only files you own in
/tmp: copy the capture and the key log there first, as your own user.
Safety
All these outputs hold things you may not want to share.
- The trace and the capture hold paths, file names, sizes, owner and group names, hashes and both endpoint ids. They never hold file content. The trace ends up wherever the logs go, such as the systemd journal for a daemon run as a service.
pbwalk’s output holds what the capture holds.- The key log holds secrets that decrypt every connection it covers. Together with a packet capture of the same connection, it gives away everything sent, file content included.
The capture file is made readable by you only, and so is a key log file
that did not exist before. Delete
them when you are done, check them before attaching them to an issue, and
unset SSLKEYLOGFILE afterwards: every irsync run, and every other program
that honours the variable, keeps writing to it while it is set.
Performance
How to find out where irsync spends its time, and how to tell whether a change made it faster. Watch a transfer with telemetry covers irsync’s own timings; this page adds the method and the system tools.
Method
- Measure before changing anything. Pick one workload that shows the problem and write down its numbers on the current commit. A guess about where the time goes is a hypothesis, not a finding: the cost is often somewhere no one expects (SQLite re-preparing a statement on every call, for example; see Known costs).
- Keep the workload fixed and reproducible. Generate the tree with filegen from a fixed seed, run the daemon and the client on the same machine with release builds, and reset the state the run depends on (the destination tree, and the index and resume state described in Files and state) the same way every time. Use an idle machine: on a busy one, single runs of the same binary vary by up to 2x.
- Compare binaries, not commits in your head. Build each version you
compare into its own file (
cp target/release/irsync /some/dir/irsync-old) and interleave their runs: old, new, old, new. Check that each run did the same work (-vshows files and bytes transferred) and that the trees match afterwards (diff -r), or the faster run may simply have done less. The Overhead benchmark of the telemetry is a worked example: interleaved runs, pooled medians, and CPU time reported beside wall time. - Prefer counts to times. CPU time, context switches and syscall counts vary far less between runs than wall time, and they say what changed. Report wall time too, but over several runs.
- Find the cause before fixing it. Go from the coarse to the fine: the
-vvsummary for the phase,perf statfor CPU against waiting,perf recordfor the hot code,strace -cfor the syscalls. When a profile shows a cost but not its caller, count the calls per call site with temporary code (a counter keyed by#[track_caller]’s location works well), then remove it. - Change one thing, then measure again with the same workload and the
same commands. Bisect when a regression’s cause is unclear: build the
commits in between with
git worktreeand run each. - Record the result in the commit message: the workload, the numbers before and after, and what did not change.
Host setup for perf
Linux restricts what an unprivileged perf may see. Two sysctls matter:
| Setting | Value needed | Why |
|---|---|---|
kernel.perf_event_paranoid | 1 or lower | Lets your user record kernel samples of its own processes. At 2 perf sees user space only; some distributions default higher still, which blocks unprivileged perf altogether. |
kernel.kptr_restrict | 0 | Shows kernel symbol addresses in /proc/kallsyms. At 1, your user sees all-zero addresses, so perf records kernel samples but cannot name them. |
Check the current values first, so you can restore them:
sysctl kernel.perf_event_paranoid kernel.kptr_restrict
One-off, until the next reboot:
sudo sysctl kernel.perf_event_paranoid=1
sudo sysctl kernel.kptr_restrict=0
Persistent, applied at every boot:
sudo tee /etc/sysctl.d/99-perf.conf <<'EOF'
kernel.perf_event_paranoid = 1
kernel.kptr_restrict = 0
EOF
sudo sysctl --system # applies it now as well
To undo it, delete /etc/sysctl.d/99-perf.conf and reboot, or set the values
you noted back with sysctl.
head -2 /proc/kallsyms shows non-zero addresses once kptr_restrict is in
effect.
These settings weaken the kernel’s defences slightly. Every local user can then profile its own processes in kernel mode and read kernel addresses, which makes kernel exploits easier. That is fine on a single-user development machine. Do not leave them set on a shared or production host.
Tools
-vv summary. Add -vv to the client. The block at the end of each
session shows wall time, busy time per activity (walk, plan, hash, write,
waiting on the peer, …), CPU and wire bytes, for the client and the daemon.
Start here to see which phase and which side to look at.
Telemetry. --debug-addr serves span timings and flamegraph input over
HTTP. These are irsync’s own spans, so they show time per phase rather than
per function. See Watch a transfer with telemetry.
perf stat. CPU time and context switches for a whole process:
perf stat -e task-clock,context-switches irsync daemon --config irsync.toml
High CPU points at computation. Many context switches point at threads
handing work to each other (with tokio, every spawn_blocking round trip
costs futex wake-ups). Wall time much longer than CPU time means the process
is waiting: on disk, on the network, or on a lock.
perf record. Where the CPU time goes, with call stacks. Build with frame
pointers into a separate target directory, so the normal build stays cached:
RUSTFLAGS="-C force-frame-pointers=yes" CARGO_TARGET_DIR=target/fp \
cargo build --release -p irsync
perf record -F 999 -g -o perf.data target/fp/release/irsync daemon --config irsync.toml
perf report -i perf.data --no-children
The prebuilt standard library has no frame pointers, so stacks that pass
through it can be cut short. perf record --call-graph dwarf avoids that,
at the cost of much larger data files. Kernel frames need the host setup
above.
strace -c. Syscall counts and errors per syscall:
strace -f -c -o strace.txt irsync daemon --config irsync.toml
The errors column is often the useful part: tens of thousands of failing
calls (a mkdir getting EEXIST, a statx getting ENOENT) are work that
can usually be skipped. strace slows the traced process by an order of
magnitude, so use its counts, not its times.
Syscalls per call site. When strace -c shows a count worth cutting,
find which code makes the calls. strace -k prints a stack for every
syscall, and tools/syscall-sites.py groups the calls by syscall, result
and the innermost irsync frames. Use a small workload (a few hundred
files), since every call writes a full stack:
CARGO_PROFILE_RELEASE_DEBUG=line-tables-only CARGO_TARGET_DIR=target/dbg \
cargo build --release -p irsync
strace -f -k -e trace=statx,fstat,newfstatat -o trace.txt \
target/dbg/release/irsync daemon --config irsync.toml
# ... run the client against it, then stop the daemon ...
tools/syscall-sites.py trace.txt target/dbg/release/irsync
Each output line is a count, the syscall and where it was called from, innermost frame first (the line numbers depend on the build):
142 statx ENOENT part_exists (part_file.rs:353) < open_from (part_file.rs:560) < poll (session/receiver/file_io.rs:461)
142 statx (fd) open_locked_part (part_file.rs:435) < open_part_in_dir (part_file.rs:464) < open_sized_part (part_file.rs:1220)
Divide by the number of files to get calls per file, then look for one file paying for the same answer twice: two fstats of the same descriptor, an lstat whose result the next call would report anyway, a call whose outcome is already known. Count again after a change; the same command shows whether each site went away.
Two details the script handles:
- strace prints a frame’s offset in the file, while
addr2linewants a virtual address. The script adds the executable segment’s address minus its offset (readelf -lW), and steps each return address back by one so it lands in the call. - With
-f, a call interrupted by another thread is printed as<unfinished ...>and later<... resumed>, with its stack after the resumed line. The script attaches it to the right call.
The line tables do not change the code, so counts from this build match
the normal release build. -k needs an strace built with stack-trace
support (strace -k -e trace=openat true prints stacks if it has it).
Known costs
- SQLite re-preparing a statement. A statement whose plan depends on a
bound value (
?2 IS NULL OR path > ?2,LIMIT ?3) can be re-prepared on every execution. Inperf reportthis shows up assqlite3Reprepare. Spell such variants into the SQL text, so each one is prepared and cached once. - WAL commits empty other connections’ page caches. Each commit makes
every other connection reread the pages it touched. Fewer, larger commits
(the index writer batches what arrives within 10 ms,
LINGERincrates/irsync/src/index.rs) and memory-mapped reads (PRAGMA mmap_size) keep that cheap. A largercache_sizedoes not help, because the misses are invalidations, not capacity. - Blocking-pool round trips per file. With tens of thousands of small
files, the number of
spawn_blockingcalls per file matters more than what each one does. Doing a file’s related blocking steps in one call saves a thread hand-off, with its futex wake-ups, per step. - Syscalls that are expected to fail. Creating a directory that already exists, or checking a path that is not there, costs a syscall per file. Trying the operation that usually succeeds, and recovering only when it fails, removes them.
Design records
The book describes irsync as it is. Why it is that way is recorded in
docs/ in the repository: one decisions file per component, each entry
naming what was decided, why, and what it costs if the ruling turns out to
be wrong. Where a decisions file and the code disagree, the code is what
shipped.
| Record | What it holds |
|---|---|
| IRSYNC_DECISIONS.md | irsync’s design and implementation decisions that the code does not show (its numbered rulings), and the points knowingly left open. |
| FILESET_DECISIONS.md | The rulings made while building fileset. |
| FILEGEN_DECISIONS.md | The rulings made while building filegen. |
| IRSYNC_HARNESS_DECISIONS.md | The rulings made while building irsync-stress, the irsync bugs the harness found, its acceptance run and its sweeps. |
| NETSTRESS_DECISIONS.md | The calls made while building irsync-netstress and its fault layer, and the results of the real runs. |
| SUPPLY_CHAIN_DECISIONS.md | How the way from a commit to a user’s install is guarded, and the trade-offs taken. |
docs/superpowers/
is history: the specs (specs/), implementation plans (plans/) and
progress ledgers (ledgers/) that features were built from. They are not
updated as the code changes; read them for the reasoning at the time, and
the book and the code for the current state.
Open ideas, in no particular order, are in TODO.md.
Releasing
You start a release by hand, with one command. GitHub Actions tests the commit and builds the files, and leaves a draft GitHub Release. Then you sign the files on your own computer with an offline key, and publish the draft. Publishing creates the tag. You never push a release tag. This page says how to cut a release, what the workflows do, what to do when one fails, and what to set up once.
Only three kinds of version release anything:
| Version | What it is | Where it goes |
|---|---|---|
X.Y.Z | A stable release | GitHub Release, Homebrew, apt, dnf |
X.Y.Z-beta.N | A beta | GitHub Release only |
X.Y.Z-alpha.N | An alpha | GitHub Release only |
The tag is the version with a v in front: vX.Y.Z. Any other version
stops the gate with an error within seconds, before the tests. Nothing is
published.
Where a release is cut from
Every release of the line X.Y is cut from the branch release-X.Y:
its alphas, its betas, X.Y.0 and its patches. A line goes through these
steps, in this order:
X.Y.0-alpha.1,X.Y.0-alpha.2, …X.Y.0-beta.1,X.Y.0-beta.2, …X.Y.0, then the patchesX.Y.1,X.Y.2, …
A beta follows an alpha or a lower beta. A stable release follows an alpha,
a beta or a lower stable release. Going back is refused: no alpha after a
beta, no beta after X.Y.0. A line may skip steps and start with a beta
or with X.Y.0. The gate allows that, with a warning that it is not the
usual order. Pre-releases are only of X.Y.0: there is no
X.Y.1-beta.1.
Until X.Y.0 is out, release-X.Y follows main. Before each alpha,
beta and X.Y.0, the workflow release-prepare.yml creates
release-X.Y at main, or rebases it onto main. Rebasing replays the
branch’s own commits, if it has any, on top of main. Once X.Y.0 is
out, the branch no longer moves with main, and only takes fixes.
main and every release-X.Y branch only take changes through a pull
request that passed the CI result check. The one exception is
release-prepare.yml, which pushes release-X.Y with a deploy key (see
One-time setup). The gate refuses to run on the wrong
branch, and refuses a version out of the line’s order.
Cutting a release
There are three cases. They differ only in where the version bump goes:
mainis on the line. A pre-release orX.Y.0whilemainstill works towardsX.Y, including the first alpha of a new line. The bump goes tomain, thenrelease-prepare.ymlbringsrelease-X.Yup tomain(step 5).mainhas left the line.mainalready holds a later version, such as1.4.0-alpha.1while1.3is still in beta. The bump goes torelease-X.Ythrough a pull request, andrelease-X.Ydoes not move withmainany more.- A patch (
X.Y.ZwithZabove 0). The bump goes torelease-X.Y.
bump-version.sh works out which case it is, from the version and from
origin/main, and prints the right commands.
-
Fetch, and switch to the branch the bump goes to, up to date and with no uncommitted changes. Run the bump script with the new version, without the
v:git fetch origin git switch main && git pull --ff-only # or release-1.2 .github/scripts/bump-version.sh 1.2.3It stops if you are on the wrong branch, and names the right one. It sets the version in
Cargo.toml([workspace.package]) andpackaging/dist/dist.toml, and updatesCargo.lockandfuzz/Cargo.lockto match. It commits the four files asRelease v1.2.3on a new branch,bump-v1.2.3. It doesn’t push or tag. It prints the commands for the next steps. -
Write the release notes: a section
## v1.2.3inCHANGELOG.md, above the older ones, and commit it on the bump branch. See The release notes for what goes in it.git commit -m 'Release notes for v1.2.3' -- CHANGELOG.md -
Open a pull request against the branch the bump goes to. Use
--base:git push -u origin bump-v1.2.3 gh pr create --fill --base main # or release-1.2 -
Wait for its
CI resultcheck to pass. That includes therelease buildjobs, which run the Linux release build the way the release will. Then merge it:gh pr merge --merge. Onmain, the merge also rebuilds the site: dev.irsync.org shows the new version and its documentation from then on, before it is published (see The release versions and The books). Until the release is published, the site cannot be promoted to irsync.org. -
If the bump went to
main, bringrelease-X.Yup tomain. Startrelease-prepare.ymlonmain, with the version:gh workflow run release-prepare.yml --ref main -f version=1.2.0-beta.1It checks that
mainholds the version and that nothing of the line is being released, then waits for you to approve therelease-branchenvironment. Then it createsrelease-1.2atmain, or rebases it ontomain. If the rebase conflicts, it pushes nothing; see If the rebase conflicts. Skip this step when the bump went torelease-X.Y. -
Start the release gate on
release-X.Y, with the version:gh workflow run release-gate.yml --ref release-1.2 -f version=1.2.3In the browser: Actions, Release gate, Run workflow, pick the branch, enter the version.
-
When the gate is done, it prints
Draft ready. Sign it:and the commands. Plug in the USB stick with the release key and sign the draft, with the version:.github/scripts/sign-release.sh --key /media/$USER/irsync-key/irsync-release.key 1.2.3It checks the draft, asks you to confirm, asks for the key’s password once, signs every file and uploads the signatures. The release stays a draft. Look at it on GitHub.
-
Publish it by running the same command with
--publish:.github/scripts/sign-release.sh --key /media/$USER/irsync-key/irsync-release.key --publish 1.2.3It signs again, publishes the release and starts the resume run. It also re-runs the newest staging build of the site, which now reads the release from its tag. See Signing the release.
-
Put the new version on irsync.org. The script ends by printing the command. Wait for the staging run it started, check that dev.irsync.org shows the version and that
/book/there documents it, then run:gh workflow run site.yml --ref main
A bump that lands on release-X.Y does not rebuild the site, but
publishing the release does.
For a pre-release, use a version such as 1.3.0-beta.1 or 1.3.0-alpha.1.
If the rebase conflicts
When release-X.Y has commits of its own that clash with main,
release-prepare.yml stops and pushes nothing. Its error names the files.
Rebase the branch by hand into a branch of your own, then hand that in:
git fetch origin
git switch -c fix-1.3 origin/release-1.3
git rebase origin/main # resolve each conflict, git add, git rebase --continue
git push origin fix-1.3
gh workflow run release-prepare.yml --ref main -f version=1.3.0-beta.2 -f fixed-branch=fix-1.3
The workflow checks the fixed branch: it must start at the current main,
have no merge commits, and hold only commits of release-1.3, in the same
order (a commit main already has may be left out). Then it makes it
release-1.3 and deletes fix-1.3. If someone moved release-1.3
meanwhile, it pushes nothing; start it again.
Don’t start the gate twice for the same version while one run is going. The second run deletes the draft the first one made.
The release notes
Every release has a section in CHANGELOG.md, at the root of the
repository, under a heading that is exactly ## v and the version:
## v1.2.3
One or two sentences on what this release is about.
### Upgrading
- What someone who runs the previous release has to do or know.
### New
### Fixed
It is written for people who run irsync, not for people who read the code: what is new, what changes for them, what was fixed. Leave out a part that has nothing in it. A stable release sums up the betas and alphas before it, since most people go from one stable release to the next.
dist reads the section and puts it at the top of the GitHub Release, under
Release Notes, so it is in the draft you look at and sign. The full list
of changes still follows it (see below). These checks keep a release from
going out without its notes:
- A test (
crates/irsync/tests/release_version.rs) fails whenCHANGELOG.mdhas no section for the version inCargo.toml, so the pull request with the bump cannot passCI resultwithout one. - The release gate stops within seconds when the section is missing or
empty (
.github/scripts/changelog-section.sh).
A pull request that only touches Markdown skips the tests. So CI also runs
that script on every pull request, and an edit to CHANGELOG.md that
breaks the section of the current version fails CI result too.
A change merged after the notes were written and before the gate starts is in the release and not in the section. The full list below it has it.
Changing the version by hand
If you change the version by hand instead, keep all four files in step. These checks catch a mismatch:
- A test (
crates/irsync/tests/release_version.rs) fails ifCargo.tomlanddist.tomldiffer. - CI builds with
--locked, so it fails ifCargo.lockis out of date. The release build uses--lockedtoo, and would fail later. Thecheckandfuzz-buildjobs do the same forfuzz/Cargo.lock. - The release gate stops within seconds if the two files don’t hold the version you gave it.
Copying a fix to a release branch
Fixes go to the lines that have not reached X.Y.0 yet, and to the
newest stable line. Land the fix on main first. Before X.Y.0, a line
whose branch still follows main gets the fix with the next
release-prepare.yml run, and needs nothing else. For any other line,
copy the fix to its branch with a pull request (here for release-1.2):
git switch release-1.2 && git pull --ff-only
git switch -c fix-short-name
git cherry-pick -x <commit>
git push -u origin fix-short-name
gh pr create --fill --base release-1.2
-x writes the original commit into the message. Merge the pull request
once CI result passes. Then release the patch as above, from
release-1.2.
Before X.Y.0, a commit added to release-X.Y this way stays on it: each
release-prepare.yml run replays it on top of main, and drops it once
main has the same change.
What the workflow does
You start .github/workflows/release-gate.yml by hand. It is the only way a
release starts. It does this, in order:
- Check. It checks the version, that it runs on the right branch, and
that the version in
Cargo.tomlandpackaging/dist/dist.tomlis the one you gave. It checks thatCHANGELOG.mdhas the release notes of that version (see The release notes). It checks that the tag doesn’t exist yet and that there are no stray release tags (see Protecting the release tags). It checks thatrelease-X.Yexists and that the version follows the line’s earlier releases (see Where a release is cut from). This takes seconds. - Test. It runs
ci.ymlon the branch’s commit, with the musl release targets added. If anything fails, it stops. Nothing is published, and no tag exists. - Pin. It makes a branch
pinned/vX.Y.Zat the tested commit, so the release builds exactly that commit even if the branch moves on. Don’t merge a change to a workflow file into the branch while the gate runs: GitHub then refuses to let the gate make this branch (see If a release fails). It deletes apinned/vX.Y.Zleft over from an earlier failed attempt. It refuses to go on if arelease.ymlrun from an earlier attempt is still going. It also deletes a draft release left over for the tag. - Draft. It launches
release.ymlon the pinned branch and waits for it.release.ymlbuildsirsyncandfilesetfor Linux x86_64, Linux arm64 and macOS on Apple Silicon. Each tarball also holds the man pagesirsync(1),fileset(1)andirsync.toml(5), built from the book with pandoc. It creates a draft GitHub Release with the tarballs, checksums, our installerirsync-installer.shand the Homebrew formula, each with an attestation. (The signatures added later have none.) A draft is not public and has no tag. It still takes new files. The gate then deletes thepinned/branch and prints the command that signs and publishes the draft. It ends there.
You then run .github/scripts/sign-release.sh, on your own computer (see
Signing the release). It signs the files and
publishes the draft. Publishing creates the tag vX.Y.Z. That is the point
of no return: the release is immutable from then on, and no file on it can
be replaced or added. The script then starts
.github/workflows/release-resume.yml on the new tag. That run does the
rest, because the secrets of the release environment open only for runs
on a v* tag:
- Packages and Homebrew (stable releases only). Both jobs wait for
you to approve the
releaseenvironment. Open the resume run, click “Review deployments”, tickreleaseand approve: one click lets both start..github/workflows/packages.ymlbuilds the.deband.rpmfiles from the released Linux tarballs. It signs the.rpmfiles, adds everything toirsync-dev/packages, signs the apt and dnf metadata and pushes. It keeps the newest 3 versions. GitHub Pages serves the result atdist.irsync.org. The packages get attestations, but are not attached to the release..github/workflows/publish-homebrew.ymlpushes the formula from the release toirsync-dev/homebrew-tap. First it runs.github/scripts/formula-man-pages.sh, which adds two lines to the formula (man1.installandman5.install), so brew puts the man pages wheremanlooks. This happens before the tap is checked out with its token. The script fails if dist’s formula template changed, so look at the formula then.
- Notes. It adds GitHub’s list of changes to the release notes, below
what the draft already has, under the heading
## What's changed. For a stable release the list starts at the previous stable release, so it covers the betas in between too.
The release tag is a lightweight tag made by GitHub, not an annotated one.
The install script site/install.sh (served as irsync.org/install.sh)
picks the newest release for its channel: stable by default, --beta for
betas and stable, --alpha for all. --require-signature makes it fail
when it cannot check the installer’s minisign signature. Other arguments
go to the installer irsync-installer.sh that release.yml attached to
the release. It puts the programs in ~/.local/bin and the three man
pages in ~/.local/share/man/man1 and man5, and has no updater. It writes no
receipt and never edits the shell’s startup files. If ~/.local/bin is not
on PATH, it prints the line to add. --uninstall removes the two
programs and the three pages. Before it places
anything, it checks that it can write to ~/.local/bin and both man
directories. If it cannot write to ~/.local/bin, it stops and changes
nothing. If it cannot write to a man directory, it installs the programs
without the pages and prints a warning that names the directory.
It accepts the flags dist’s installer took (--no-modify-path, --quiet,
-q, --verbose, -v) and IRSYNC_NO_MODIFY_PATH, and ignores them, so
scripts written for dist’s installer keep working; -h is --help. dist’s
install directory variables (IRSYNC_INSTALL_DIR,
CARGO_DIST_FORCE_INSTALL_DIR and IRSYNC_UNMANAGED_INSTALL) are refused:
when one is set, the installer stops before it does anything, since it
always installs under ~/.local. On an Apple Silicon Mac under
Rosetta it installs the Apple Silicon build. Intel Macs are not supported.
Its source is packaging/installer/irsync-installer.sh.in.
The release workflow is generated
.github/workflows/release.yml is made by
.github/scripts/release-yml.sh from what dist generate writes (cargo
dist 0.34.0), with --draft added so the release is created as a draft.
dist does not manage the file any more (allow-dirty = ["ci"] in
dist-workspace.toml). Never edit it by hand. The settings are in
dist-workspace.toml, and the package is described in
packaging/dist/dist.toml. After you change dist-workspace.toml, run:
.github/scripts/release-yml.sh write
and commit the result. .github/scripts/release-yml.sh check says whether
the file is up to date; CI runs it.
The installer is not dist’s. dist-workspace.toml lists
irsync-installer.sh under extra-artifacts, and dist builds it with
packaging/installer/build-installer.sh, which fills in the version and the
checksums of the three tarballs. The man pages get into the tarballs through
packaging/dist/build.sh, which runs tools/build-man.sh. The build
runners need pandoc, which dist-workspace.toml lists as a dependency.
This needed no change to release.yml: the workflow
reads the runners’ packages and the extra artifact from dist plan when it
runs.
release.yml only starts when the gate launches it. Never launch it by
hand from the Actions tab. That skips the tests.
If a release fails
The tag is created when you publish the draft, so a failure before that leaves no tag behind. Fix the cause and start the gate again with the same version. It deletes a leftover draft.
The site cannot be promoted. From the merge of the bump until the
release is published, the promote refuses the staging build: it shows a
version nobody can install yet. Publish the release, or, if the release is
abandoned, land the next bump or promote with allow-unpublished (see
Promoting to irsync.org).
The check failed. Nothing ran. Read the error. Usually the version in
the two files does not match, CHANGELOG.md has no notes for the version,
or you are on the wrong branch, or the branch release-X.Y is missing
(run release-prepare.yml first), or the version is out of the line’s
order. Fix it and start the gate again.
A stray tag is different: see
Protecting the release tags.
The test step failed. Nothing was published, and no tag exists. If it was a flaky test, use “Re-run failed jobs” on the gate run. If the failure is real, fix it on the branch through a pull request, then start the gate again with the same version.
The pin step failed. Nothing was built or published, and no tag exists. The usual cause: a change to a workflow file was merged into the branch while the tests ran. GitHub does not let the gate’s built-in token create a branch then, and answers “Resource not accessible by integration”. The error names the workflow files that changed and the command that starts the gate again; run it, on the branch’s new commit.
The release step failed. Look at the release.yml run it launched. The
link is in the gate’s log. If the gate could not find the run, look in the
Actions tab under the release workflow: it may still be running.
- If the draft was not created, or you don’t trust it, nothing was published
and there is no tag. Fix the cause, then start the gate again with the
same version. A leftover
pinned/vX.Y.Zbranch and a leftover draft are deleted by the next run. If arelease.ymlrun is still going, the gate refuses to start: cancel that run first (gh run cancel <id>), or wait for it to end. - If the draft was created but the gate lost track of the
release.ymlrun, the draft is fine. Sign it withsign-release.sh, then publish it withsign-release.sh --publish.
Signing failed. See Signing the release.
The tag exists, but the release is not finished. The gate refuses to start again, since the tag can’t be reused. Finish the release with the resume workflow (see below).
The packages or Homebrew step failed. Fix the cause (often a token in
the release environment), then re-run that job from the resume run, or
start a new resume run. Both are safe to run again. If the packages repo
already has this version, the packages job builds nothing and changes
nothing there. If the tap already has the formula, the Homebrew job pushes
nothing.
The notes step failed. Re-run that job, or start a new resume run. It does nothing if the heading is already there.
The release is out, but the packages, Homebrew or the notes did
not happen. This is what you see if the resume run was cancelled, or
sign-release.sh could not start it. Start the
resume run by hand:
gh workflow run release-resume.yml --ref v1.2.3 -f tag=v1.2.3
Two traps:
- Cancelling the gate run does not stop
release.ymlonce it has been launched. Cancel that run too, from the Actions tab. - Starting the gate twice for the same version makes the second run delete the first run’s draft. Don’t.
Finishing a release with the resume workflow
.github/workflows/release-resume.yml is the second half of every release:
sign-release.sh starts it on the new tag. You start it yourself to
finish a release that already exists but whose resume run failed or never
ran. It runs the same branch, packages, Homebrew and notes steps. It never
builds or publishes a release. Start it on the tag, so the release
environment opens. In the browser, go to Actions, Release resume, Run
workflow, and pick the tag under “Use workflow from”. Or run:
gh workflow run release-resume.yml --ref v1.2.3 -f tag=v1.2.3
It stops with an error if it runs on anything but that tag. It checks that
the tag is a release tag and that its GitHub Release exists and is
published. For a stable release it runs the packages and Homebrew steps
(after you approve release) and the notes. For a pre-release it only adds
the notes. It runs the scripts as they were at the tag. A fix to a release
script on main reaches the next release, not this one.
With -f dry-run=true it builds and signs the packages, for any release,
pre-releases too. It checks that the token may push to the packages repo,
but publishes nothing: no push, no Homebrew, no notes. The packages and the
updated repo are kept as artifacts of the run, for you to look at. Use it
on a pre-release to check the key and tokens before the first stable
release.
Signing the release
Every file on a release gets a minisign
signature, FILE.minisig, made with a key that never goes near GitHub. The
.sha256 files are signed too. Someone who takes over the GitHub
organisation or a workflow can build a release, but can’t sign it. The
reasons are in Supply chain security. The one-off key
setup is in The release signing key.
sign-release.sh runs on your computer, with the key’s USB stick plugged
in. It stops at the first check that fails:
- The draft holds exactly the files a release should have.
- Every checksum matches, and every file has an attestation from
release.yml. - You confirm the list of files.
- minisign signs all files in one go and asks for the password once. The
trusted comment of every signature is
irsync vX.Y.Z. - Every signature checks out against
packaging/signing/release-keys.pub. A wrong key is caught here. - It uploads the
.minisigfiles and checks that every file has one. - It checks that the tag still does not exist. Then it publishes the
draft, which creates the tag, checks that the release is immutable and
starts
release-resume.ymlon the tag. Then it re-runs the newest staging build of the site, so the site reads this release from its tag. If that cannot be started, for example because that run is still going, it prints the commands to do it by hand; the release is published either way. GitHub lets a run be re-run for 30 days. After that, a push tomainthat touchessite/orbook/rebuilds the site. It ends by printing the command that promotes the site to irsync.org; it does not run it.
Step 7 only happens with --publish. Without it, the script stops after
step 6 and the release stays a signed draft: look at it, then run the
script again with --publish. Publishing can’t be undone, so it never
happens by accident.
--key PATH names the secret key file. Without it, minisign uses
~/.minisign/minisign.key.
Where the key lives. The secret key is a password-protected file on a
USB stick, and a copy is on a second stick kept somewhere else. The password
is in a password manager. Nothing of it is on GitHub. The public key is in
packaging/signing/release-keys.pub.
A second key. Another maintainer makes their own key, as in
A second key, and a pull request
adds their public key to release-keys.pub below the first one. A release
signed with either key passes. The new key can sign from the first release
that lists it.
If signing fails. Nothing is public until the last step, and the script only uploads files to the draft.
- A check fails before the upload (files, checksums, attestations, the key): read the message, fix the cause and run the script again.
- Something fails after the upload but before the publish: run the script again. It replaces the signatures.
- You can’t fix it, or the build itself is wrong: delete the draft
(
gh release delete vX.Y.Z) and start the gate again with the same version. It deletes a leftover draft anyway. - The release is published, but the resume run did not start: start it by hand (see Finishing a release with the resume workflow). Never run the script on a published release: it refuses.
Once the release is published, its files can’t change. A wrong signature means a new version.
Testing a version on FreeBSD
FreeBSD is not a release target yet. Until it is, one workflow checks a version there by hand and gives you a tarball to try. It never blocks a pull request or a release, and nothing starts it for you.
Start it with the tag or branch to test, then fetch the result:
gh workflow run freebsd.yml -f ref=v0.1.0-beta.4
gh run watch
gh run download <run-id> -n irsync-x86_64-unknown-freebsd
Without -f ref=... it tests the branch the run starts on, main by
default. The download holds irsync-x86_64-unknown-freebsd.tar.xz, laid out
like the release tarballs, and its .sha256 file.
The run builds on FreeBSD 14: a binary built on 14 also runs on newer
releases, and not the other way round. -f freebsd=15 picks another
release.
Inside the VM it runs tools/ci.sh check freebsd-build as an ordinary
user, with the Rust version in rust-toolchain.toml. That is the full
regression, then the release build. A failing test means no tarball.
Nothing is cached in the VM, so a run takes a while.
The limits:
- x86_64 only.
- A version from before this workflow existed can’t be tested. The run uses the scripts of the version under test, and stops with a message when they are missing.
- The tarball is not on the release page, and it has no attestation.
- irsync does not upload itself to a FreeBSD server over ssh. Install the two programs there by hand.
One-time setup
Do this once, before the first release.
Repositories. Create two public repositories in the irsync-dev
organisation. Create both with a README, so they have a main branch:
homebrew-tap, for the Homebrew formula.packages, for the apt and dnf repo.
GitHub Pages. In the packages repository, turn on Pages and serve the
default branch. Set the custom domain to dist.irsync.org and turn on
“Enforce HTTPS”. You don’t fill the repository by hand. Each stable release
copies index.html, irsync.repo and CNAME from packaging/repo/ into
it, and exports the public key as irsync.asc (for dnf) and irsync.gpg
(for apt).
DNS. Add a CNAME record that points dist.irsync.org at
irsync-dev.github.io. If the DNS is on Cloudflare, set the record to
“DNS only” (grey cloud), so GitHub can issue the HTTPS certificate.
Signing key. Make a GPG key with the user ID
irsync releases <releases@irsync.org>, step by step in
Making the signing key. Set up the
releases@irsync.org mailbox too, so mail to that address reaches someone.
The workflow uses the fingerprint of the key it imports as GPG_KEY_ID, so
there is nothing else to set.
Release signing key. Make the minisign key that signs every file on a release, step by step in The release signing key. It stays offline, on a USB stick, and never goes into GitHub.
Tokens and secrets. Make one fine-grained token per repository, and put
the secrets in the release environment, not the repository. Step by step
in Supply chain security, steps 2 to 5:
Secret (environment release) | What it holds |
|---|---|
PACKAGES_GPG_PRIVATE_KEY | The signing subkey only: private-subkey.asc |
PACKAGES_GPG_PASSPHRASE | The key’s passphrase: passphrase.txt, with no newline at the end |
PACKAGES_REPO_TOKEN | A token that can push to irsync-dev/packages and nothing else |
HOMEBREW_TAP_TOKEN | A token that can push to irsync-dev/homebrew-tap and nothing else |
Old release-* branches. Before you apply the settings, delete every
remote branch that matches release-* and is not a release-X.Y release
branch. Examples are old PR branches like release-v0.1.0-beta.3 and
release-via-pr. The Release branches ruleset would make them
undeletable. List them with:
git ls-remote --heads origin 'release-*'
and delete each one with git push origin --delete <name>.
Release branch key. release-prepare.yml pushes release-X.Y with a
deploy key. The Release branches ruleset lets every deploy key of the
repository past, so this must be the only one; tools/github_settings.py check reports any other. Make the key, add it, store its private half in
the release-branch environment, and delete both files:
ssh-keygen -t ed25519 -N '' -C release-branch -f release-branch
gh repo deploy-key add release-branch.pub --title release-branch --allow-write
gh secret set RELEASE_BRANCH_KEY --env release-branch < release-branch
rm release-branch release-branch.pub
Run tools/github_settings.py apply first, so the environment exists.
Applying never creates the key, so the private half never passes through
that tool.
Repository settings. tools/github_settings.py apply sets the
rulesets (including the release tags and
the release branches), the environments, secret scanning and immutable
releases. See Checking the settings.
Creating release-X.Y by hand
release-prepare.yml creates release-X.Y. A line released before it
existed has no branch: create it at the line’s newest release. For the
0.1 line:
git push origin v0.1.0-beta.6:refs/heads/release-0.1
The Release branches ruleset refuses to create the ref for a person. An
admin disables that ruleset for a moment, pushes the branch, and turns the
ruleset on again with tools/github_settings.py apply.
Watch the first prepare run. The first run of release-prepare.yml is
the first push through the deploy key. If the ruleset blocks it, check
tools/github_settings.py check: the Release branches ruleset must let
deploy keys past, and the key must have write access.
Watch the first patch release. The first release from a release-X.Y
branch should be watched. The gate creates pinned/vX.Y.Z with the
workflow’s built-in token, and GitHub may refuse that if the workflow files
on the branch differ from those on main. If it does, that is a bug to
fix. Don’t work around it by pushing tags.
The first release
Do the one-time setup first. Then:
-
Merge to
main. (Done.) The gate can only launchrelease.ymlonce it is on the default branch, so the merge comes first. The install steps in the README and the book go live with it. They say that Homebrew, apt and dnf start with v0.1.0, and that--alphaworks before that. -
Put the install script on irsync.org. (Done.) The merge deploys the site, with
install.sh, to staging. Check thathttps://dev.irsync.org/install.shis there, then promote the site (see Promoting to irsync.org). -
Rehearse with a pre-release. Done:
0.1.0-alpha.1was rehearsed this way, with the old flow. Its tag exists and it has no release, so the start check refuses that version now. The next rehearsal uses the next pre-release, for example0.1.0-beta.4. Follow Cutting a release with that version, including the signing step. Publishing the draft creates the tag.Check that:
- the gate passes and leaves a draft, and
sign-release.shpublishes it and creates the tagv0.1.0-beta.4; - the GitHub Release is marked as a pre-release and has the tarballs, the
checksums, the installer and a
.minisigfile for each of them, and they verify as in Verify a download; - its notes end with
## What's changed; - the install script with
--alphainstalls it, and without--alphasays there is no stable release yet; - after that install,
man irsyncshows the released version in its footer, andman filesetandman irsync.tomlwork; --uninstall(with--alpha) removes the programs and the three pages;- nothing went to Homebrew, apt or dnf.
If a Mac with Rosetta is at hand, also run the install script once in a Rosetta shell (
arch -x86_64 sh). It should say it runs under Rosetta and install the Apple Silicon build. The tests only fake this, with a stand-insysctl.Then install the pre-release’s formula with real Homebrew, with the man page lines added the way
publish-homebrew.ymladds them. It goes into a throwaway local tap, since Homebrew may refuse a formula file that is not in a tap. On a Mac with Homebrew, from a clone of this repository:gh release download v0.1.0-beta.4 --repo irsync-dev/irsync --pattern irsync.rb .github/scripts/formula-man-pages.sh irsync.rb brew tap-new --no-git local/rehearsal cp irsync.rb "$(brew --repository local/rehearsal)/Formula/" brew install local/rehearsal/irsync man -w irsync fileset irsync.toml brew uninstall irsync brew untap local/rehearsal rm irsync.rbman -wshould print a path under Homebrew’sshare/manfor each of the three pages. - the gate passes and leaves a draft, and
-
Dry-run the packages on the pre-release. A pre-release skips Homebrew, apt and dnf, so the steps only stable releases run have not run yet. Once the rehearsal release from step 3 is published, run them without publishing:
gh workflow run release-resume.yml --ref v0.1.0-beta.4 -f tag=v0.1.0-beta.4 -f dry-run=trueThis uses the GPG secrets, the packages repo token, nfpm and Ubuntu’s rpm. Check that the run passes. Download its two artifacts and look at them: the
.debfiles list/usr/bin/irsyncand/usr/bin/filesetand the three man pages under/usr/share/man(dpkg-deb -c), and the.rpmfiles are signed (rpm -Kv, afterrpm --importofirsync.ascfrom the repo artifact). -
Check the Homebrew token. Nothing has used
HOMEBREW_TAP_TOKENyet. Push a throwaway branch to the tap with it, then delete the branch. When git asks, give any user name and the token as the password. Thecredential.helper=setting stops git from using your own login instead:git clone https://github.com/irsync-dev/homebrew-tap cd homebrew-tap git -c credential.helper= push origin HEAD:refs/heads/token-check git -c credential.helper= push origin --delete token-check -
Cut v0.1.0. Follow Cutting a release with the version
0.1.0. Then check the Homebrew formula, the apt and dnf repo atdist.irsync.org, and the signed.rpmfiles on the release.
The packages repo grows
Every release adds a commit with new package files to irsync-dev/packages.
Pruning removes old files from the tree, but git keeps them in the history,
so the repository keeps growing. Pages serves only the current tree, so the
history is not needed. Once in a while, when no release is running, replace
it with a single commit:
git clone https://github.com/irsync-dev/packages
cd packages
git checkout --orphan fresh
git commit -m "Packages, history squashed"
git push --force origin fresh:main
If main is protected against force pushes, allow it for this push.
Protecting the release tags
Release tags are created by GitHub when sign-release.sh publishes the
draft release. That is not a push. Never push a v* tag yourself. The
Release tags ruleset, set by tools/github_settings.py, makes every v*
tag permanent once it exists:
| Rule | What it stops |
|---|---|
| Restrict updates | Moving an existing tag to another commit |
| Restrict deletions | Deleting a tag |
| Block force pushes | Overwriting a tag with git push --force |
Nobody can bypass it, admins included. Creating tags is allowed, and
publishing a draft creates one, so the ruleset doesn’t get in the way. A
stable release still publishes nothing beyond the GitHub Release until a
maintainer approves the release environment.
A tag pushed by hand has no GitHub Release. It is a stray tag. It can’t be
deleted, and it uses up its number. The gate checks for stray tags and
stops every release until you have dealt with them: release a later
version. The two old alpha tags, v0.1.0-alpha.1 and v0.1.0-alpha.2, were
pushed before releases came with the tag. They are the only ones the check
accepts without a release.
Two more rulesets protect the branches a release runs on:
Release branchescoversrelease-*. Likemain, a branch there takes changes only through a pull request that passedCI result, and can’t be deleted or force-pushed.Pinned release commitscoverspinned/*. The gate creates and deletes these branches, but nobody can move one or force-push to it.
Check all of it, stray tags included, with:
tools/github_settings.py check
Making the signing key
The key signs the apt and dnf repositories at dist.irsync.org. The steps
below make it, test it the way the workflow uses it, and leave you with the
files for the two GPG secrets. They take about ten minutes.
The key is RSA 4096, can only sign, has no subkeys and never expires:
- RSA works with every apt and rpm we care about, including older RHEL rpm versions that can’t check newer key types.
- The workflow signs with the first secret key it finds, so one key with no subkeys is all it needs.
- apt users keep the public key in a file on their machine. If the key
expired,
apt updatewould fail for everyone until they downloaded it again. The revocation certificate covers a lost or leaked key instead.
The passphrase is long and random. Nobody types it; it lives only in the secret and in your backup.
1. A separate keyring. Use a machine you trust, and keep the key out of
your everyday keyring. GNUPGHOME tells gpg which keyring to use, for this
terminal only, so run every later step in the same terminal:
umask 077
mkdir ~/irsync-signing-key
cd ~/irsync-signing-key
export GNUPGHOME="$PWD/gnupg"
mkdir -m 700 "$GNUPGHOME"
gpg --list-secret-keys # prints nothing: the keyring is empty
2. The passphrase. 40 random characters, with no newline at the end. The workflow uses the secret byte for byte, so a trailing newline would become part of the passphrase and signing would fail:
gpg --gen-random --armor 1 30 | tr -d '\n' > passphrase.txt
wc -c passphrase.txt # 40
3. The key. rsa4096 is the key type, sign means it can only sign,
and never is the expiry date. --pinentry-mode loopback with
--passphrase-file takes the passphrase from the file instead of a
password prompt:
gpg --batch --pinentry-mode loopback --passphrase-file passphrase.txt \
--quick-generate-key 'irsync releases <releases@irsync.org>' rsa4096 sign never
FPR=$(gpg --list-secret-keys --with-colons | awk -F: '$1 == "fpr" { print $10; exit }')
echo "$FPR"
gpg --list-keys
FPR is the fingerprint, the key’s 40-character ID. gpg --list-keys
shows one rsa4096 key with usage [SC], no expiry, and the user ID
irsync releases <releases@irsync.org>.
4. Export the files.
gpg --batch --pinentry-mode loopback --passphrase-file passphrase.txt \
--armor --export-secret-keys "$FPR" > private-key.asc
gpg --armor --export "$FPR" > public-key.asc
cp "$GNUPGHOME/openpgp-revocs.d/$FPR.rev" revocation.rev
head -1 private-key.asc # -----BEGIN PGP PRIVATE KEY BLOCK-----
| File | What it is | Where it goes |
|---|---|---|
private-key.asc | The private key, still protected by the passphrase | Your backup only. GitHub gets a signing subkey, private-subkey.asc, made in Supply chain security step 2 |
passphrase.txt | The passphrase | PACKAGES_GPG_PASSPHRASE, and your backup |
revocation.rev | Declares the key dead, even without the private key | Your backup only |
public-key.asc | The public key | Your records; every stable release publishes it as irsync.asc and irsync.gpg |
gpg made the revocation certificate together with the key. Anyone who has it can kill the key, so it never goes into GitHub.
5. Test the files the way the workflow uses them. First make the
signing subkey (Supply chain security
step 2). The workflow imports private-subkey.asc into an empty keyring,
takes the first fingerprint it finds (the primary key’s, whose secret part
isn’t there) and signs with the passphrase, which uses the subkey. Do the
same in a second empty keyring:
export GNUPGHOME="$PWD/ci-test"
mkdir -m 700 "$GNUPGHOME"
gpg --batch --import private-subkey.asc
TEST_FPR=$(gpg --batch --list-secret-keys --with-colons | awk -F: '$1 == "fpr" { print $10; exit }')
[ "$TEST_FPR" = "$FPR" ] && echo "fingerprint matches"
echo test > test.txt
gpg --batch --yes --pinentry-mode loopback --passphrase-file passphrase.txt \
--local-user "$TEST_FPR" --clearsign -o test.txt.asc test.txt
gpg --verify test.txt.asc
You should see fingerprint matches and Good signature from "irsync releases <releases@irsync.org>". A warning that the key is not certified
with a trusted signature is normal. Then remove the test keyring:
gpgconf --kill gpg-agent
rm -rf "$GNUPGHOME" test.txt test.txt.asc
export GNUPGHOME="$PWD/gnupg"
6. The secrets. Reading from a file keeps the passphrase out of your shell history:
gh secret set PACKAGES_GPG_PRIVATE_KEY --env release --repo irsync-dev/irsync < private-subkey.asc
gh secret set PACKAGES_GPG_PASSPHRASE --env release --repo irsync-dev/irsync < passphrase.txt
gh secret list --env release --repo irsync-dev/irsync
In the browser instead (Settings, Environments, release), paste the whole
of private-subkey.asc, including the
BEGIN and END lines, and the 40 passphrase characters with nothing
after them. GitHub never shows a secret again, so if you are unsure you
pasted it right, set it again.
7. Back up, then clean up. Keep private-key.asc, passphrase.txt and
revocation.rev somewhere safe outside GitHub, such as a password manager
that takes attachments or an encrypted USB stick. Write the fingerprint
(echo "$FPR") next to them: it is how anyone checks that a downloaded
irsync.asc is the real key. Without the backup, losing the secret means a
new key, and every user has to import it again.
Once you have checked that you can open the backup, delete the working folder:
gpgconf --kill gpg-agent
cd ~
rm -rf ~/irsync-signing-key
unset GNUPGHOME
8. Check it on a real run. An alpha doesn’t sign anything, so the first real use of the key is the dry run in The first release, step 4. A wrong passphrase secret fails there. After the first stable release, check that the published key is yours:
curl -fsSL https://dist.irsync.org/irsync.asc | gpg --show-keys
The fingerprint it shows must match the one you wrote down.
If the key leaks, mark it revoked where users fetch it, then rotate to a new key (below). In a throwaway keyring, import the public key and the revocation certificate, and export the result:
gpg --import public-key.asc revocation.rev
gpg --armor --export "$FPR" > irsync.asc
gpg --export "$FPR" > irsync.gpg
Commit these two files to the packages repository by hand. Anyone who
fetches the key from then on gets it marked revoked, and the next stable
release replaces both files with the new key. Users who already have the
old key keep trusting it until they import the new one, so tell them
(rotation step 4). If the key is lost with no backup, make a new key
and rotate.
Rotating the signing key
- Make the new key, with the same user ID, as in Making the signing key.
- Put the new key’s signing subkey and passphrase into the
PACKAGES_GPG_PRIVATE_KEYandPACKAGES_GPG_PASSPHRASEsecrets of thereleaseenvironment (Supply chain security, steps 2 and 4). If only the subkey leaked, replace the subkey instead and keep the key. - Cut a stable release. It signs the metadata with the new key and
publishes the new public key as
irsync.ascandirsync.gpg. - Tell users to import the new key again. For apt, that means downloading
irsync.gpgagain to/etc/apt/keyrings/. For dnf, the.repofile fetches the key fromirsync.asc; dnf asks to trust the new one.
Old packages stay signed with the old key until they are pruned from the repo (after 3 newer versions). Until then, users who have not re-imported the key may see signature errors on those files.
The user-facing install steps
The README, the book’s introduction and the fileset introduction list the
ways to install, and what the install script does and how to uninstall.
Keep the three in step. The apt and dnf commands are in packaging/repo/index.html
(the page at dist.irsync.org). If you change them there, change them in
the docs too.
Supply chain security
irsync runs on machines that hold people’s data, often as a daemon, so a backdoored irsync would be a backdoor into all of them. This page lists what guards the way from a commit to a user’s install, and the steps only a maintainer can do. Why each choice was made is in SUPPLY_CHAIN_DECISIONS.md.
What guards what
Someone takes over the repository.
- Two-factor login is required for the
irsync-devorganisation. mainonly changes through a pull request that passed theCI resultcheck. Nobody can push to it directly or force-push, admins included. A pull request needs no approving review while irsync has one maintainer.- Release tags (
v*) are created by GitHub when a maintainer publishes the draft release, not by a push. They can never be moved or deleted. Anyone with write access can still push a newv*tag by hand. That is caught, not blocked: a tag with no release stops the next gate run, andtools/github_settings.py checkreports it. release-*branches take changes only through a pull request that passedCI result, likemain. The one exception is the deploy keyrelease-branch, with whichrelease-prepare.ymlcreatesrelease-X.Yor rebases it ontomain. Its private half lives in therelease-branchenvironment, which opens only for runs onmainand only after a maintainer approves; the job that checks the version holds no secret. A ruleset can’t name one deploy key, so it lets every deploy key past, and the settings check reports any key but this one. Thepinned/*branches the gate makes can’t be moved.- The signing key and the tokens for the packages repo and the Homebrew tap
live in the
releaseenvironment. It opens only for jobs running on av*tag, and only after a maintainer approves. A change merged tomaincan’t reach them. No secret is stored repo-wide; the settings check reports one if it appears. - The Cloudflare tokens live in the
siteenvironment, which opens only for runs onmain. - Every Action is pinned to a commit, not a version tag its owner could
move.
.github/scripts/tests/test_workflow_policy.pyfails CI when a workflow breaks one of these rules. - Secret scanning and push protection catch a secret before it’s pushed.
A dependency goes bad.
-
cargo deny --locked checkruns on every change (deny.toml). It fails on:- any RustSec advisory, including unmaintained or yanked crates;
- a license that isn’t on the list;
- a crate from anywhere but crates.io and the pinned upstream iroh commit;
- a second version of a crate that isn’t listed as accepted (see Accepting a second version of a crate).
An exception in
deny.tomlthat no longer matches anything also fails the check, so a stale one gets removed.It looks at the crates built for the platforms irsync and its tools are built for, listed under
targetsindeny.toml. Both Windows targets are there, becausefilegenandfilesetare built for them, so the check covers every crate only a Windows build uses, those of the whole workspace and iroh’s too. A crate built only for a platform not listed (illumos, say) is left out. Add a platform there when something of ours starts building for it.One advisory is accepted today: RUSTSEC-2026-0543, because
chronois unmaintained. It is built on Windows only, throughnetwatch(iroh); see issue 174. Among the accepted duplicates, one is temporary:nix0.31, whichctrlc3.5.2 asks for while everything else is on 0.32. It goes whenctrlcmoves to 3.5.3, which is not before 2026-11-25. The reasons are indeny.tomland in Accepting an advisory and Accepting a second version of a crate. -
The licenses of every crate in
Cargo.lock, for every platform, are checked too (deny-license-check.toml, thedeny-license-checkjob). A failure there shows on a pull request without blocking it, but it stops a release. The two files must allow the same licenses; a test checks that. -
The same advisory check runs daily (
advisories.yml), so a new advisory against untouched code is noticed. -
Dependency review flags a pull request that adds a vulnerable crate.
-
Dependabot proposes updates weekly, but only once a release is 7 days old. Most hijacked releases are pulled within days. Security fixes come without the wait.
Someone swaps a binary.
- Every archive, installer and package gets an attestation. Users can check
one with
gh attestation verify, see Verify a download. - Every file on a release is signed with a minisign key that is kept
offline, on a USB stick, and never goes into GitHub. A maintainer signs
the draft on their own computer and then publishes it
(
.github/scripts/sign-release.sh, see Releasing). Someone who takes over the organisation, a token or a workflow can build a release, but can’t make a signature that passes. Users check it as in Verify a download. The one-off key setup is in The release signing key. - Releases are immutable once published: no file can be replaced or added.
install.shrefuses plain HTTP, even after a redirect.- The apt/dnf key’s primary part is kept offline. GitHub holds only a signing subkey, which can be revoked and replaced without users trusting a new key.
A bug slips in.
- Fuzzing feeds the code that reads bytes from a peer millions of made-up
inputs and watches for a crash. The seeds are checked on every pull
request, and each target is fuzzed for ten minutes every night
(
nightly.yml). A crash fails the run and uploads the input, which is public, as the Fuzzing section of Testing explains. - Every
unsafeblock needs a// SAFETY:comment, and clippy refuses one without. Miri runs the tests it can run every night, and stops at undefined behaviour (memory use the language does not allow). - zizmor checks the workflows for security problems, in the
workflowsjob. CodeQL, GitHub’s code analysis, reads the Rust code and the workflows, and shows what it finds in the Security tab. It is not a required check until it has been quiet for a few weeks. See Static analysis.
Someone finds a vulnerability.
- There are two ways to report it: the Report a vulnerability button on
the repository’s Security tab (private vulnerability reporting), or an
email to
security@irsync.org. SECURITY.md says so. - A report is answered within 7 days.
tools/github_settings.py checkreports the setting if it is turned off.
The Scorecard
The OpenSSF Scorecard grades a public repository on
about 18 security habits, such as pinned Actions, a security policy and
fuzzing, and gives each a score from 0 to 10 and the project an overall
score out of 10. scorecard.yml runs it on every push to main, every
week, and when the branch protection settings change. The result is at
scorecard.dev,
the badge in the README links to it, and the findings also show in the
Security tab.
The score describes the project as it is. We do not change anything only to raise it. At the time of writing (2026-11-20) it is 6.0 out of 10. Most of the gap is in the checks below, which we accept or which rise with time. Every check not listed here scores 10 (or is marked “not applicable”, as Packaging is: irsync has no package registry).
| Check | Score | Why it is low | What we do |
|---|---|---|---|
| Maintained | 0 | The repository is younger than 90 days. | Rises by itself in February 2027. |
| Code-Review | 0 | No change has been approved by a second person, because irsync has one maintainer. | Accepted. Changes when more maintainers join (see below). |
| Branch-Protection | 3 | main needs a pull request and a passing CI result, but no approving review (one maintainer). It also does not require a branch to be up to date before merging, which would mean a rebase for every pull request. | Accepted. The approval part changes when more maintainers join. |
| Contributors | 0 | All contributors belong to one organisation. | Accepted. We can’t change this. |
| CII-Best-Practices | 0 | irsync has no OpenSSF Best Practices badge. It is a form the maintainer fills in. | Later. |
| Signed-Releases | 3 | Scorecard looks at the last five releases. Only the two newest are signed, and none has provenance (a signed record of how it was built). | Rises with each signed release. The old ones can’t be changed. |
| Token-Permissions | 0 | release.yml is written by dist and has contents: write at the top. The release jobs also need their write permissions to publish. Scorecard scores any such write as a failure. | Accepted. |
| Pinned-Dependencies | 8 | Three downloads are piped into a shell without a hash: the dist installer in release.yml (two places) and the rustup install in tools/dev-setup.sh. Every Action is pinned. | Accepted. The first two are written by dist, the third is a developer setup script. |
| Vulnerabilities | 9 | Scorecard reads every entry in Cargo.lock, also for crates that are not built for the platforms irsync ships on. One advisory is left: chrono is unmaintained. It is built on Windows only, through iroh. cargo deny also checks the Windows targets now, so it sees chrono; it passes because deny.toml accepts that one advisory, with the reason, and no other. | We asked upstream to drop it. See issue 174. |
The scores move when the repository changes and when Scorecard changes its checks, so read the live result for the current numbers.
Checking the settings
tools/github_settings.py holds the settings for irsync-dev/irsync,
irsync-dev/iroh, irsync-dev/homebrew-tap and irsync-dev/packages.
These are the rulesets, environments, deploy keys, secret scanning, SHA
pinning, immutable releases and private vulnerability reporting. apply
never adds or removes a deploy key; it says what to do by hand.
tools/github_settings.py check # prints every difference, changes nothing
tools/github_settings.py apply # sets them; needs an org admin
apply creates the main ruleset only once the checked-out commit has a
passing CI result check. Otherwise every pull request would wait on a
check that never reports. Run check now and then, and after changing a
setting by hand.
Accepting an advisory
When cargo deny fails on an advisory, first try to upgrade:
cargo update -p <crate>, or bump the version in Cargo.toml. If you
can’t yet, accept it in deny.toml under [advisories], with the ID and
the real reason:
ignore = [
{ id = "RUSTSEC-2026-0000", reason = "no fixed version yet; irsync never calls foo()" },
]
Remove the entry once a fix is in. A reason like “not used” without saying why is not a reason.
Accepting a second version of a crate
Each copy of a crate is more code to build, ship and keep an eye on. So
cargo deny fails when a crate is in the tree in more than one version,
unless deny.toml lists that version under skip in [bans]. A routine
cargo update or a new dependency can set this off.
First see who pulls in each version:
cargo tree -i aes-gcm@0.10 --all-features -e normal,build,dev
If one of our own crates or a direct dependency is behind, update it. If the
older version comes from a crate we don’t control, accept it: add the older
version to skip, with the crate that pulls it in as the reason:
skip = [
{ crate = "aes-gcm@0.10", reason = "noq-proto (iroh) uses aes-gcm 0.10" },
]
Write the version without the last part (0.10, or 2 for 2.x), so a
patch release doesn’t need a change here. Each version gets its own entry.
skip-tree, which accepts a crate and everything below it, would also hide
the next duplicate in that part of the tree.
When upstream catches up and the older version is gone, the entry no longer matches and the check fails until you remove it.
Maintainer steps
These need a person. Do them in order. Secret values can’t be read back from GitHub, so each one is entered fresh.
1. Two-factor login. Add a passkey or a hardware key to your GitHub
account (Settings, Password and authentication), not SMS. Then, in the
irsync-dev organisation, go to Settings, Authentication security, and
tick “Require two-factor authentication”.
Dependency graph. In irsync-dev/irsync, go to Settings, Code
security, and enable “Dependency graph”. The dependency review job in CI
needs it, and there is no API to turn it on.
2. Split the signing key. The primary key stays offline. GitHub gets only a signing subkey. Use the separate keyring from Making the signing key:
export GNUPGHOME="$PWD/gnupg"
FPR=$(gpg --list-secret-keys --with-colons | awk -F: '$1 == "fpr" { print $10; exit }')
gpg --batch --pinentry-mode loopback --passphrase-file passphrase.txt \
--quick-add-key "$FPR" rsa4096 sign never
SUB=$(gpg --list-secret-keys --with-colons "$FPR" | awk -F: '$1 == "fpr" { n++ } n == 2 { print $10; exit }')
gpg --batch --pinentry-mode loopback --passphrase-file passphrase.txt \
--armor --export-secret-subkeys "$SUB"'!' > private-subkey.asc
gpg --armor --export "$FPR" > public-key.asc
The ! exports exactly that subkey. It sits in single quotes so that
zsh and bash don’t read it as history expansion. private-subkey.asc goes into GitHub.
Keep private-key.asc, passphrase.txt and the revocation certificate
offline. Users keep trusting the primary fingerprint, which doesn’t change.
The subkey never expires, like the key itself: apt users keep the public key
in a local file that nothing refreshes, so an expiry date would break
apt update for all of them on that day.
If the subkey leaks, revoke it in this keyring (gpg --edit-key "$FPR",
key 1, revkey, save), add a new one as above, and replace the secret.
Then commit the re-exported public-key.asc to the packages repo as
irsync.asc and irsync.gpg, as in rotation step 3. The fingerprint users
trust stays the same, but apt and dnf only learn the new subkey when they
download the key file again, so tell users to (rotation step 4).
3. Tokens. Make two fine-grained personal access tokens, each limited to one repository with “Contents: read and write” and nothing else:
| Token | Repository |
|---|---|
for HOMEBREW_TAP_TOKEN | irsync-dev/homebrew-tap |
for PACKAGES_REPO_TOKEN | irsync-dev/packages |
4. Environments and their secrets. Run tools/github_settings.py apply
first: it creates the release and site environments. Then:
gh secret set --env release HOMEBREW_TAP_TOKEN
gh secret set --env release PACKAGES_REPO_TOKEN
gh secret set --env release PACKAGES_GPG_PRIVATE_KEY < private-subkey.asc
gh secret set --env release PACKAGES_GPG_PASSPHRASE < passphrase.txt
gh secret set --env site CLOUDFLARE_API_TOKEN_DEV
gh secret set --env site CLOUDFLARE_API_TOKEN_PUB
gh secret set --env site CLOUDFLARE_ACCOUNT_ID
gh secret set asks for a value when nothing is piped in.
5. Delete the old repository-wide secrets, so only the environments hold them:
for s in HOMEBREW_TAP_TOKEN PACKAGES_REPO_TOKEN PACKAGES_GPG_PRIVATE_KEY \
PACKAGES_GPG_PASSPHRASE CLOUDFLARE_API_TOKEN_DEV CLOUDFLARE_API_TOKEN_PUB \
CLOUDFLARE_ACCOUNT_ID; do gh secret delete "$s"; done
gh secret list # prints nothing
Before the first stable release, check the key and tokens with a resume dry run on a pre-release. See Finishing a release with the resume workflow.
When more maintainers join
These are settings changes in tools/github_settings.py, not a redesign:
- the
mainruleset requires one approving review; - add a
CODEOWNERSfile so changes to.github/,packaging/,dist-workspace.toml,deny.tomlandsite/install.shneed a maintainer’s review; - the
releaseenvironment getsprevent_self_review, so whoever starts a release can’t also approve it. This is not enough alone: the resume run is started bygithub-actions[bot], not by the person who started the gate, so the setting would not stop that person from approving their own release.
The release signing key
Every file on a GitHub Release is signed with
minisign, a small signing tool. The
key that makes those signatures never goes near GitHub. It lives on a USB
stick, and a maintainer signs each release on their own machine with
.github/scripts/sign-release.sh (see Releasing). Because
the key is not on GitHub, someone who takes over the GitHub organisation or
a workflow still can’t make a release that passes the check.
This is a different key from the GPG key that signs the apt and dnf
repositories (Making the signing key).
That one lives in GitHub, in the release environment.
This page makes the key, once. It takes about fifteen minutes. At the end you have:
- the secret key, a file protected by a password, on a USB stick and on a backup stick,
- the password, in your password manager,
- the public key, committed as
packaging/signing/release-keys.pub. Everyone may see it: irsync,install.shand users check signatures against it.
What you need
minisign 0.10 or newer. Older versions make signatures in an old format that irsync refuses.
sudo apt install minisign # Debian, Ubuntu
sudo dnf install minisign # Fedora
brew install minisign # macOS
minisign -v # minisign 0.11 or similar
Two USB sticks, ideally encrypted (LUKS on Linux, an encrypted APFS volume on macOS). One holds the key you sign with, the other is the backup.
A password manager for the key’s password.
Making the key
1. Open the stick. Plug in the first stick and note where it is mounted. Run every later step in the same terminal:
KEYDIR=/media/$USER/irsync-key # macOS: /Volumes/irsync-key
umask 077 # new files readable by you only
ls "$KEYDIR"
2. Choose the password. Let your password manager make a long random one, at least 20 characters, and save it there under “irsync release key”. You type it once per release, so it doesn’t need to be easy to remember.
3. Make the key pair. minisign asks for the password twice:
minisign -G -p "$KEYDIR/irsync-release.pub" -s "$KEYDIR/irsync-release.key"
cat "$KEYDIR/irsync-release.pub"
The public key file has two lines. The first is a comment with the key ID, 16 hex digits that name the key. The second is the key itself:
untrusted comment: minisign public key 1A2B3C4D5E6F7A8B
RWSLejxNPCsaG...
The secret key file is encrypted with the password. The file alone is useless without the password, and the password alone is useless without the file.
4. Test the key the way a release uses it. Sign a test file with a
trusted comment, as sign-release.sh does with irsync vX.Y.Z, then check
it:
cd "$(mktemp -d)"
echo test > test.txt
minisign -S -s "$KEYDIR/irsync-release.key" -t "irsync v0.0.0-test" -m test.txt
minisign -V -p "$KEYDIR/irsync-release.pub" -m test.txt
The last command prints Signature and comment signature verified and
Trusted comment: irsync v0.0.0-test.
Then check the signature format. The first two bytes of the signature must
be ED, which means minisign hashed the file before signing it. Ed means
the old format: upgrade minisign, delete the two key files and start again
at step 3.
sed -n 2p test.txt.minisig | base64 --decode | head -c 2; echo # ED
Finally, check that a changed file fails:
echo changed >> test.txt
minisign -V -p "$KEYDIR/irsync-release.pub" -m test.txt # Signature verification failed
5. Make the backup. Copy both files to the second stick and keep it somewhere else, away from the first stick and from your computer:
cp "$KEYDIR/irsync-release.key" "$KEYDIR/irsync-release.pub" /media/$USER/irsync-key-backup/
The password stays in the password manager, never on either stick.
6. Publish the public key. In your irsync checkout, on a branch, copy the public key into the repository and open a pull request:
cp "$KEYDIR/irsync-release.pub" packaging/signing/release-keys.pub
release-keys.pub is the one place the public key lives. irsync builds it
in, and the tests check that site/install.sh holds the same key. Also
update the key shown in README.md and in
Verify a download in the same pull
request.
7. Put the stick away. Unmount it and unplug it. It only needs to be plugged in while you sign a release.
Where the secret key must never go
- Into GitHub in any form: not a secret, not an environment, not the repository, not an issue.
- Into CI, or any machine you don’t control.
- Into a folder that syncs to the cloud (Dropbox, iCloud Drive, Google Drive, OneDrive).
- Into the irsync checkout, where a careless
git addcould commit it.
Signing a release
Plug in the stick, then follow Releasing. The signing step is:
.github/scripts/sign-release.sh --key "$KEYDIR/irsync-release.key" 1.2.3
It asks for the password once and signs every file on the draft release.
Check the draft on GitHub, then run the same command with --publish
before the version to publish it. Unplug the stick when it is done.
A second key
So that releases don’t depend on one person, another maintainer can make
their own key with steps 1 to 5, on their own sticks and with their own
password. Add their public key to release-keys.pub below the first one,
both lines of it. A release signed with either key passes. Also add the
key to README.md and book/src/how-to/verify-a-download.md.
A new key can sign from the first release that lists it. An irsync that is
already installed only checks downloads of its own version, which were
signed with the key in use back then, and install.sh comes from the
website with the current keys.
If the key is lost or leaked
Lost: both sticks are gone, or the password is. Make a new key with the
steps above, add its public key to release-keys.pub, remove the old one,
and release. Tell users the new key in the release notes, since anyone who
checks downloads by hand needs it.
Leaked: someone else may have the key file and the password. Do the same as for a lost key, and in addition:
- Say so in the release notes and in a security advisory, with the old key ID.
- Tell users to upgrade: irsync binaries released before the change still trust the old key.
This website
irsync.org has two parts, built from this repository into one directory: a
landing page at / and this book. The book is there several times, once
per release channel: see The books. The book as on main
lives on dev.irsync.org/dev/, which is
deployed on every push; irsync.org holds the releases and changes only when
someone promotes.
Layout
| Path | What it holds |
|---|---|
site/index.html, site/404.html, site/favicon.svg, site/robots.txt, site/_headers, site/install.sh | The landing page, the page served for an unknown URL outside /book/, and the files served next to them, copied as they are. |
site/tailwind.css | The landing page’s stylesheet: the Tailwind CSS and daisyUI source that the build compiles into style.css. |
site/package.json, site/package-lock.json | The npm packages the stylesheet is built with, pinned. Not deployed. |
site/tokens.json | The design tokens of the landing page and the book: colours, font stacks, text sizes, radius. |
site/tools/ | gen_tokens.py (tokens to CSS), strip_font_link.py (see Building), versions.py (see The release versions), label_book.py (see The books), check.py (the checker) and their tests. Not deployed. |
site/build.sh, site/serve.sh, site/deploy.sh | Build, serve locally and deploy. Not deployed. |
site/wrangler.jsonc | The settings both Cloudflare Workers are deployed with. Not deployed. |
book/ | The mdbook: book.toml, the pages in book/src/, theme overrides in book/theme/ (irsync.css; picker.js, which trims the theme picker; home-link.js, which links the title to the landing page; a11y.js, which adds the skip link; favicon.svg, the same icon as the landing page’s). |
The design tokens
site/tokens.json holds the design of both the landing page and the book:
every colour (light and dark), font stack, text size and corner radius.
Edit it here. The build turns it into CSS custom properties named --ir-*,
in two git-ignored files:
site/tokens.css, whichsite/tailwind.cssimports: light on:root, dark under the system’s dark setting.book/theme/tokens.css, keyed on the theme class mdbook puts on<html>: Light and Rust take the light values, Coal, Navy and Ayu the dark ones.
A few colours are for the book only (warn-ink, danger-ink and the
-soft tints); their usage says so. site/tools/test_gen_tokens.py
pins the landing page’s colours and checks that text colours are readable
(4.5:1) on the grounds they are used on. Changing a landing page colour
means changing that test too, on purpose.
The landing page design
The landing page is styled with Tailwind CSS
and daisyUI, from site/tailwind.css. Its look comes
from network cabling: deep navy ink, aqua (the jacket colour of multimode
fibre) for the route through the steps and for every link and button, and
single-mode yellow kept for the beta warning only.
- Colours come from
site/tokens.json(see The design tokens), light first and swapped for dark by the system setting. One daisyUI theme,irsync, refers to them, so it needs no dark twin. Colours with no daisyUI name are Tailwind colours of their own:muted,aqua,link,signal,on-signaland thetermcolours of the command strips. Writetext-mutedorbg-base-200, not a raw colour. - Type is three families, all shipped as web fonts, Latin only.
Barlow (
font-display), a typeface modelled on road signs, for the headline, buttons, the header and the footer, in regular (400) and semibold (600); its narrower Barlow Semi Condensed (font-condensed), in semibold for the labels in running text, at the size of the text around them (“No open ports.”, “Beta.”), and for the step headings, and in regular (400) for the release versions. Inter (font-body) for running text, and JetBrains Mono (font-mono) for commands. The stacks and the text sizes are insite/tokens.json. Text sizes are the named stepstext-display,text-heading,text-lede,text-body,text-smallandtext-label; inline code is 0.9 of the text around it (codein the scale, inem). - The route. The steps under Get started are stations on one aqua line
(the
stationutility); keep it for content that really is a sequence.
The release versions
On the line of the “Install” heading, the landing page shows the current
irsync versions, one per release channel: the channel, the version and its
date. They are for someone who has irsync already and wants to know
whether to install again. Each version is a button that copies the install
command of its channel. The channel’s name links to that channel’s book
(stable/, beta/, alpha/), and the date to the release on GitHub.
Of each channel only the newest version counts. Then:
- The stable is shown.
- The beta is shown if it is newer than the stable.
- The alpha is shown if it is newer than the stable and the beta, even a beta that is itself not shown.
| Newest stable / beta / alpha | Shown |
|---|---|
| none / 0.1.0-beta.5 / 0.1.0-alpha.4 | beta |
| 0.1.0 / 0.1.0-beta.7 / 0.1.0-alpha.4 | stable |
| 0.1.0 / 0.2.0-beta.1 / 0.2.0-alpha.3 | stable, beta |
| 0.1.2 / 0.2.0-beta.1 / 0.3.0-alpha.1 | stable, beta, alpha |
The first one shown is the main version. The install command on the page
installs it: the command ends in | sh for a stable, and in
| sh -s -- --beta or | sh -s -- --alpha otherwise. The “beta” badge in
the header and the yellow note under the steps show only while there is no
stable release, and name the main version’s channel.
site/tools/versions.py works this out when the site is built, from git.
The page looks nothing up in the browser.
- A published release is its
v*tag. GitHub creates the tag when the release is published. - A release that is being built is the version in
Cargo.toml, on the checked-out commit and on everyorigin/release-X.Ybranch, when no tag has it yet. So the site shows a release from the merge of its bump on. - The date is the day of the commit the tag points at, as
git logshows it. For a release that is being built, it is the day its version came onto the branch.
site/index.html marks the places the build fills in with comment pairs,
<!-- versions:NAME --> and <!-- /versions:NAME -->: lines (the
version lines), tail (the end of the install command), prerelease (the
badge and the note, dropped once there is a stable), and channel and
Channel (the channel’s name inside those). Opened straight from the
repository, the page shows no versions. The markup of a version line is
in versions.py; site/tailwind.css reads its classes from there.
The build stops with an error when a marker is missing from the page, or
when the checkout has no release tags. Fetch them with
git fetch --tags.
The books
The site holds the book five times, so that someone who runs a release reads the documentation of that release:
| Path | Which book |
|---|---|
/book/ | The main version: the one the install command on the landing page installs |
/stable/ | The newest stable release |
/beta/ | The newest beta |
/alpha/ | The newest alpha |
/dev/ | The working tree: main on the site, your edits when you build locally |
The build holds all five, and dev.irsync.org serves them all. irsync.org
serves all but /dev/: the promote leaves it out. So the dev book is
always https://dev.irsync.org/dev/, up to date with main within
minutes of a push, and irsync.org changes only when someone promotes, at a
release or for a change to the landing page.
A channel’s book is there whenever the channel has a version, also when the
landing page hides that version as obsolete. A channel with no version has
no directory. /book/ is a full copy of its channel’s book, not a
redirect.
The versions come from git, as for the landing page (versions.py). Each
book is built from the pages (book/src) of its version’s commit: the tag
of a published release, or the branch tip of a release that is being built.
Everything else is today’s: book/book.toml, the theme, mdbook. So an old
book has the current look.
The build makes a working copy of each book under target/site-books/ and
never changes book/ itself. site/tools/label_book.py labels the copy:
- The title page says which version it documents, under its heading.
- “Edit this page” is only in
/dev/. A released page cannot be edited at its tag. - mdbook’s
site-urlis the book’s own path.
The build stops with an error when a version’s commit has no book/src, or
when its title page does not start with a heading.
Once mdbook has built all of them, site/tools/switcher.py adds the
version switcher to the top bar of every page: a button with the book’s
channel (Beta), which opens the list of the books, Stable, Beta and Alpha
with their versions (those that exist), then Dev with the commit it was
built from (irsync@a3cdcd6), so a glance at dev.irsync.org tells whether
a merge is live. /book/ is not in the
list; there, the channel it copies is ticked. Each link is written for the
page it is on: the same page in the other book if that book has it, else
that book’s title page. Each names the site that serves its book: Stable,
Beta and Alpha link to https://irsync.org/…, Dev to
https://dev.irsync.org/dev/…, from either site. So the dev book always
opens on dev.irsync.org, and a release book on irsync.org. check.py
checks every one of these links against the build, like any other link. book/theme/switcher.js only opens and closes the list, and
keeps the #anchor when the link stays on the same page. A plain
mdbook build book or mdbook serve book has no switcher.
The landing page has the same switcher in its header, in parentheses
after “Documentation”. switcher.py writes it between the
<!-- switcher --> markers in site/index.html, with links to each
book’s title page and the main version’s channel ticked, as in /book/.
The build copies switcher.js next to the page to open it. Opened
straight from the repository, the page has no switcher.
The landing page remembers the book picked there for the browser tab
(sessionStorage). Back on the page, the button names that book, it is
ticked, and “Documentation” opens it. The page’s other links into the book
stay on /book/: the build checks them against that book only, and
another book may not have those pages.
The build also writes VERSIONS next to BUILD: one line per book, with
its path, version, commit and published or unpublished (a release that
is being built). The dev line has no version (-). Its commit is the one
the site was built from, the same as in BUILD, and its last field is the
branch that was built, main on staging.
https://dev.irsync.org/VERSIONS shows what staging holds. The promote reads it (see
Promoting to irsync.org).
Linking from the landing page
The landing page is built from main, and /book/ from a release. Link
to book/… as before. If the released book does not have the page or the
heading yet, the checker fails and names the link. Then link to
https://dev.irsync.org/dev/… until the release has it, or wait for the
release. Never link to dev/… from outside the dev book: irsync.org has
no /dev/, and the checker refuses such a link.
The contributor guide is linked at https://dev.irsync.org/dev/, from the
landing page’s footer and from CONTRIBUTING.md: contributors work on
main.
Building
The build needs mdbook, Python 3 and Node.js with npm. It reads the release
versions from git, so it needs a checkout with the release tags. mdbook must be the
version CI builds the site with, so the pages come out the same everywhere;
the build stops on any other. tools/dev-setup.sh installs that version:
site/build.sh
It empties target/site/, generates the token CSS for both, builds the
books into target/site/book/, target/site/beta/ and so on, copies the landing page files into target/site/,
writes the release versions into index.html
and compiles site/tailwind.css into target/site/style.css. Tailwind
keeps only the classes that site/index.html, site/404.html and the
version lines in site/tools/versions.py use. The
Tailwind CLI, daisyUI and the fonts (@fontsource/barlow,
@fontsource/barlow-semi-condensed, @fontsource/inter and
@fontsource/jetbrains-mono) come from site/node_modules/ (git-ignored);
the build runs npm ci there first when it is missing or older than
site/package-lock.json. To move to newer versions, change them in
site/package.json and run npm install in site/, which updates the lock
file.
The build copies the WOFF2 files that the stylesheets name, ten in all,
and each family’s licence (the SIL Open Font License, which must ship
with the fonts) into target/site/fonts/. They are the only font files on
the site. The book shares them: book/theme/irsync.css loads them from
../../fonts/, the site’s fonts/. A bare mdbook serve has no fonts/
and falls back to the next faces in each stack. The empty
book/theme/fonts/fonts.css keeps mdbook from copying its own web fonts,
and the build removes that stylesheet and its link from every book page.
To use another weight or style, add its @font-face rule, the file to
the copy list in site/build.sh, and, for the landing page, a preload
link if it shows on the first screen.
Addresses without .html
Cloudflare serves a page x.html at the address x, and answers x.html
with a redirect to x; dir/index.html is served at dir/. mdbook writes
every link with .html, so each click in the book cost a redirect, and its
sidebar never marked the current chapter: it compares its links with the
address. So the last step of the build, site/tools/pretty_urls.py, drops
.html from every link inside the site: in the pages (the landing page
too), in each book’s sidebar script (toc-HASH.js) and in its search index
(searchindex-HASH.js). The files keep their names. Write links in
site/index.html and the book’s pages with .html (or .md) as before;
the build rewrites them. If a newer mdbook writes the sidebar script or the
search index so that the tool finds no link in it, the build stops.
site/build.sh OUT builds into OUT instead; OUT must be under target/,
because the build deletes it first. The check is on the resolved path, so a
target/ that is a symlink to somewhere outside the checkout is refused too.
The book’s look
The book takes the landing page’s design from the same tokens:
book/theme/irsync.css maps mdbook’s variables onto them. Running text
is in Inter, headings and the book’s controls (sidebar, menu bar, search)
in Barlow, code in JetBrains Mono; bold is semibold (600), the weight
that ships. mdbook sets the root font size to
62.5%, so the token sizes, in rem, are multiplied by --ir-book-rem
(1.6). Page titles use the landing page’s heading size.
The theme picker offers Auto (follow the system setting, the default),
Light and Dark; book/theme/picker.js removes Rust, Coal and Ayu and
shows Navy as Dark. A reader who chose one of the removed themes earlier
still gets the light or dark look.
The book’s title in the menu bar (“irsync Documentation”, the same in every
book) links to the landing page at
/, as the landing page’s own “irsync” links home; mdbook has no setting
for this, so book/theme/home-link.js adds the link. A click on the bar
around the title still scrolls to the top. A bare mdbook serve has no
landing page, so the link leads nowhere there. The same script stops the
title being a heading (mdbook makes it an h1 beside the page’s own), and
on a screen narrower than 520px only “irsync” is shown. The mark before
the title is the favicon’s (favicon.svg), drawn in irsync.css as a mask
in the theme’s aqua; the landing page and the 404 page have the same mark
as inline SVG before their “irsync”.
Running text is at most 35em wide, about 75 characters a line; code blocks and tables use the full 750px, which holds an 80-column line of code.
book/theme/a11y.js adds two things for keyboard users: a “Skip to
content” link as the first stop of the Tab key, before the chapters in the
sidebar, and a place in the Tab order for every code block and table that
scrolls sideways. On a touch screen the chapter links and the bar’s
controls are 44px targets.
The version switcher (see The books) reads like the bar’s
other controls, and its list looks like the theme list (irsync.css,
#irsync-book-toggle and #irsync-book-list). On the landing page,
the button reads like the header’s links (site/tailwind.css).
The checker
cargo build -p irsync
python3 site/tools/check.py --irsync target/debug/irsync target/site
python3 -m unittest discover -s site/tools -p 'test_*.py'
check.py prints one line per problem and exits non-zero if there is any.
It enforces five things:
- Links and anchors. Every relative
hrefandsrcin the built HTML resolves to a file (xtox.html, as Cloudflare serves it), and every#fragmentto anidon the target page. A link tohttps://irsync.org/…orhttps://dev.irsync.org/…is checked the same way, against the build: both sites serve it. Because irsync.org has no/dev/, a link tohttps://irsync.org/dev/…is refused, and so is a relative link intodev/from a page outside it. Other external links are not fetched. This covers the landing page and all five books. - No
.htmladdresses. No link inside the built site ends in.html(see Addresses without.html). - No fonts but the site’s own. No font file and no
fonts/directory is in the build, except Barlow, Inter and JetBrains Mono in the top-levelfonts/. - Moved files. Documents that moved into the book (the list is
MOVED_FILESincheck.py) are not referred to, by path or by bare name, from any tracked file once they are gone.docs/superpowers/is history and is skipped. - irsync flags. With
--irsync, every--flagon a documentedirsynccommand line (in a code block, or an inline code span starting withirsync) and in the first column of the tables in Command line is one that the given binary lists in--help, of the top-level command or a subcommand. A command that the help hides, such asirsync verify-signature, counts once a page uses it: the checker asks for that command’s own--help. The book in the working tree (the source of/dev/),site/index.htmlandREADME.mdare checked. A released book’s flags are not: that would need that release’s irsync.
Serving locally
site/serve.sh
It builds the site with site/build.sh --local, serves target/site/ at http://localhost:9999/ and
rebuilds whenever a file under book/ or site/ changes; open pages reload
on their own. site/serve.sh PORT serves on another port. It needs Node.js:
it runs chokidar-cli (the watcher) and browser-sync (the server) through
npx, at the versions pinned at its top. Ctrl-C stops both.
The local server ignores _headers; the headers apply on Cloudflare only.
Like Cloudflare, it serves x.html at x (browser-sync’s --extensions html).
--local makes the version switcher link to the books in the build
instead of on irsync.org and dev.irsync.org, so you can move between
your local books. The checker refuses such a build, because its links
into dev/ would break on irsync.org; never deploy one. The landing
page’s “Contributor guide” link still goes to dev.irsync.org.
Staging and production
The site is served by two Cloudflare Workers that hold only static files, no
code. Both are deployed with the settings in site/wrangler.jsonc:
| Worker | Domain | Role |
|---|---|---|
irsync-dev | dev.irsync.org | Staging. Every deploy of main lands here. |
irsync-pub | irsync.org | Production. Changes only when a staging build is promoted. |
Promotion ships the files staging served: the staging build’s output is
kept and uploaded to irsync-pub unchanged, nothing is rebuilt, except
that dev/ is left out. The dev book is served from dev.irsync.org only
(see The books). Each build
carries a BUILD file at its root holding the commit it was built from, so
https://irsync.org/BUILD and https://dev.irsync.org/BUILD show what each
one serves.
Workers rather than Cloudflare Pages, because a Cloudflare API token can be limited to a single Worker, while a Pages token can change every Pages project in the account. Each Worker gets its own deploy token, so the token that staging deploys with cannot touch production.
One-time setup
A token limited to one Worker can deploy new files to it, but cannot create
the Worker or attach its domain. So these steps are done once by someone with
full access to the Cloudflare account (npx wrangler login), and
site/wrangler.jsonc leaves the domains out, so deploys never try to change
them.
-
Create both Workers by deploying to them once, from a checkout with a built site:
site/build.sh npx wrangler deploy --config site/wrangler.jsonc --name irsync-dev --assets target/site npx wrangler deploy --config site/wrangler.jsonc --name irsync-pub --assets target/site -
Attach the domains: in the dashboard, Workers & Pages, the Worker, Settings, Domains & Routes, Add, Custom domain:
dev.irsync.orgonirsync-devandirsync.orgonirsync-pub. Cloudflare creates the DNS records;irsync.orgmust be a zone in the same account. -
Create two API tokens, each with the Workers role Editor on one Worker only: one for
irsync-dev, one forirsync-pub. Editor can deploy new versions of that Worker and nothing else. -
Store them, with the account ID (
npx wrangler whoamiprints it), as repository secrets:gh secret set CLOUDFLARE_API_TOKEN_DEV gh secret set CLOUDFLARE_API_TOKEN_PUB gh secret set CLOUDFLARE_ACCOUNT_ID
Deploying from GitHub
This is the normal way. .github/workflows/site.yml has two jobs.
The staging job runs on every push to main that touches book/,
site/, README.md, the workflow, or what the checker reads beyond them
(crates/, proto/, docs/, .githooks/, tools/). It also runs when
Cargo.toml changes: the merge of a version bump is such a push, and
staging then shows the new version. It checks out the full history, for
the release tags the build reads. It runs the tool
tests, builds the site, runs the checker, keeps target/site as the run
artifact site, and deploys it to irsync-dev. If a check fails, nothing is
deployed.
The promote job runs only when the workflow is started by hand on main.
It takes the newest push run on main and stops if that run is still going
or failed: it does not fall back to the run before it. It downloads that
run’s site artifact, refuses it if it holds a version that is not
published (see Promoting to irsync.org),
deletes its dev/, deploys the rest to irsync-pub and writes its
BUILD to the job summary.
The repository secrets CLOUDFLARE_API_TOKEN_DEV, CLOUDFLARE_API_TOKEN_PUB
and CLOUDFLARE_ACCOUNT_ID hold the credentials; each deploy step sees only
its own Worker’s token.
Promoting to irsync.org
Promote when a release is published, so that irsync.org’s books and the landing page’s versions show it, and after a change to the landing page. Nothing else needs it: the dev book is on dev.irsync.org, which every push updates.
Look over dev.irsync.org first, then start the
promote job, either in the browser (Actions, Site, Run workflow) or with:
gh workflow run site.yml --ref main
To follow it, wait a few seconds for the run to appear, then:
gh run watch $(gh run list --workflow site.yml --event workflow_dispatch \
--limit 1 --json databaseId --jq '.[0].databaseId')
When it has finished, check that irsync.org serves the staging build, still
answers an unknown URL with a 404, and is not marked noindex:
curl https://irsync.org/BUILD # the same commit as the next line
curl https://dev.irsync.org/BUILD
curl -sI https://irsync.org/nope | head -1 # HTTP/2 404
curl -sI https://irsync.org/dev/ | head -1 # HTTP/2 404: the dev book is on dev.irsync.org
curl -sI https://irsync.org/ | grep -i x-robots # prints nothing
The last check matters most: a noindex on irsync.org would drop the site
from search engines.
A version that is not published. Between the merge of a version bump and the publishing of that release, staging shows a version nobody can install yet, and its book is read from a branch that may still move. The promote refuses such a build and names the version:
versions.py: this build holds 0.1.0-beta.6, which is not published. Publish the release, re-run the staging build, then promote.
sign-release.sh --publish re-runs the staging build for you. That run
reads every release from its tag. So the usual order is: publish, wait for
the staging run, look at dev.irsync.org, promote.
In that window nothing can be promoted, not even an unrelated fix. The way out, for a fix that cannot wait or a bump that was abandoned:
gh workflow run site.yml --ref main -f allow-unpublished=true
A build from before VERSIONS existed is refused too. Re-run the newest
staging run and promote again.
The job promotes the newest CI build, not whatever dev.irsync.org serves at
that moment. The two differ only if someone deployed staging by hand with
site/deploy.sh staging after the last CI build; the BUILD comparison
above shows it. Push, or re-run the newest staging run, to bring staging
back to a CI build before promoting.
Artifacts expire after the repository’s retention period (90 days by default). When the newest staging build is older than that, the job fails with “no staging run on main” or cannot download the build; push, or re-run the newest staging run, and promote again.
Rolling back irsync.org
Every deploy is kept as a version of the Worker. To serve an older one again,
open the dashboard, Workers & Pages, irsync-pub, Deployments, pick the
version and roll back to it; or, with the irsync-pub token or a full-access
login:
npx wrangler deployments list --name irsync-pub
npx wrangler rollback <version-id> --name irsync-pub
A rollback takes effect at once and does not touch staging. The next promotion replaces it.
Deploying from a developer machine
For when GitHub Actions is not available. site/deploy.sh runs the same
checks and deploys. It uses wrangler through npx at the version pinned
at its top, and takes the credentials from CLOUDFLARE_API_TOKEN and
CLOUDFLARE_ACCOUNT_ID, or from wrangler login. A token limited to one
Worker deploys only to that Worker: staging needs the irsync-dev token
and promote the irsync-pub one.
site/deploy.sh staging
site/deploy.sh promote
Run git fetch --tags first: the page shows the versions your checkout
knows.
staging refuses a working tree with uncommitted or untracked changes. It
builds target/site/, writes the HEAD commit to target/site/BUILD,
builds irsync (cargo build -p irsync), runs the tool tests and the checker,
and refuses to deploy when either fails. Then it deploys to irsync-dev and
copies the build to target/site-staging/.
promote deploys target/site-staging/, less its dev/, to irsync-pub and prints its
BUILD. Like the job, it refuses a build that holds a version which is not
published; site/deploy.sh promote --allow-unpublished skips that. It
refuses without a target/site-staging/BUILD, and when that
BUILD differs from https://dev.irsync.org/BUILD or cannot be compared
with it: someone else may have deployed staging since, and promotion ships
only what staging serves. Run the checks under
Promoting to irsync.org afterwards.
Checking a new Worker
After the first deploy to each Worker, confirm that an unknown URL gets a 404 status and not the landing page:
curl -I https://dev.irsync.org/nope
curl -I https://irsync.org/nope
The first line of each answer should read HTTP/2 404. With
not_found_handling set to 404-page in site/wrangler.jsonc, Cloudflare
serves 404.html with that status for any path that is not a file.
Indexing
Staging is public but not indexed; production is indexed. Both serve the
same files, so the difference lives in site/_headers, which Cloudflare
applies per host: responses from dev.irsync.org carry
X-Robots-Tag: noindex, and responses from irsync.org do not.
site/wrangler.jsonc turns off the Workers’ workers.dev hosts and preview
hosts; _headers marks those noindex too, in case one is turned on.
site/tools/test_headers.py pins these rules.
Of the five books only /book/ is indexed. /stable/, /beta/,
/alpha/ and /dev/ carry X-Robots-Tag: noindex on every host: each is
a copy of /book/, an older channel or unreleased, and must not outrank
it in a search. /dev/ is on dev.irsync.org only, which is noindex as a
whole anyway; so the contributor guide is not in search results.
| Site | Path | Indexed |
|---|---|---|
| irsync.org | / (landing page) and the files next to it | yes |
| irsync.org | /book/ | yes |
| irsync.org | /stable/, /beta/, /alpha/ | no |
| irsync.org | /dev/ | not served (404) |
| dev.irsync.org | everything, /dev/ included | no |
There is no staging-only robots.txt. Promotion uploads staging’s files
unchanged, and identical files cannot carry a different robots.txt per
host. A Disallow: / would not help either: a crawler that may not fetch a
page never sees its noindex header, and can still list the URL. The one
robots.txt allows everything.