Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command line

irsync [OPTIONS] SRC... DEST
irsync [OPTIONS] HOST:[PATH]
irsync COMMAND ...

irsync --help prints the same flags with one line each; irsync COMMAND --help does so for a subcommand.

Operands

Each operand is a local path or HOST:PATH. HOST is a host alias 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 taken as an ssh destination, such as myserver or me@myserver. irsync then sets that machine up over ssh before it syncs: it copies itself there when the server has no matching build, grants this client access to any path ([immediate]), starts the daemon and saves HOST as an alias with ssh = "HOST". It prints what it did. Later runs dial the alias over iroh and do not use ssh. A sync to an alias with ssh dials once and waits at most 15 seconds (--dial-retries sets how often it retries first). When the daemon does not answer, irsync checks the server over ssh once, starts the daemon again or updates the alias, and retries with the usual --dial-retries and --reconnect settings. That check never adds back an immediate grant removed on the server. When ssh itself fails, irsync says so and tries the daemon once more with the usual settings; if that fails too, it reports both errors. A daemon that answers and refuses the client is never handled over ssh. See the quick way.

  • 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, Photos copies the directory itself.
  • A single remote operand lists instead of copying. irsync HOST: prints the exports this client may reach, one NAME PATH ACCESS line each, where ACCESS is rw or ro with the export’s read_only applied. irsync HOST:PATH prints the files a pull would fetch and writes nothing; it recurses unless --no-recursive is given. A listing does not redial: if the connection fails, it exits instead of waiting out the reconnect window.

The daemon honours the client’s flags in both directions, filters included.

rsync-compatible flags

These have rsync’s spelling and meaning. The flags that have rsync’s spelling and a different meaning follow in the next table.

FlagMeaning
-a, --archiveArchive mode, the same as -rlptgoD.
-r, --recursiveRecurse into directories (implied by -a). Without recursion only the top-level entries are transferred, and directories are skipped.
--no-recursiveTurn off the recursion that -a implies. Also spelled --no-r.
-d, --dirsWithout recursion, transfer directories without their contents.
-l, --linksCopy symlinks as symlinks. Without it they are skipped.
-p, --permsPreserve permissions.
-t, --timesPreserve modification times.
-g, --groupPreserve the group, where the receiving user may set it.
-o, --ownerPreserve the owner, only when the receiving side runs as root.
-DThe same as --devices --specials.
--devicesPreserve character and block device nodes.
--specialsPreserve FIFOs. Sockets are never copied.
-H, --hard-linksFiles linked together in the source are linked together in the destination.
-v, --verboseList 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.
-q, --quietPrint errors only. Also turns the live progress block off.
-n, --dry-runChange nothing on either side. With -v or -i, list what would be done.
-c, --checksumCompare 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, --updateSkip files that are newer on the destination.
--delete-beforeDelete before the transfer, once both sides are listed.
--delete-duringDelete each directory’s extraneous entries as the run leaves that directory, so space is freed as the run goes.
--delete-afterDelete after the transfer; what --delete does.
--max-delete NStop deleting after N removals. The run exits with code 25.
--exclude PATTERNExclude paths that match an rsync pattern: *, **, ?, [...]; a leading / anchors the pattern to the root, a trailing / matches directories only.
--include PATTERNInclude paths that match, even if a later --exclude would hide them.
--exclude-from FILERead exclude patterns from FILE, one per line. Blank lines and lines that start with # or ; are skipped.
--include-from FILERead include patterns from FILE, as --exclude-from does.
--bwlimit RATELimit the rate. 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-idsApply 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 DIRKeep 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.
--inplaceWrite 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.
--appendExtend 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-verifyLike --append, but the existing prefix is verified too.
--fsyncFlush 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.
--paranoidGuard 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, see the page linked below). 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-errorsRun the deletion pass even when a listing was cut short by I/O errors.
--statsPrint a block of transfer statistics at the end.
-i, --itemize-changesPrint rsync’s per-file change summary, the itemize codes.
-h, --helpPrint the flags.
-V, --versionPrint 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

Flagirsyncrsync
--deleteDelete 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-excludedAlso 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, --sparseLeave 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.
--timeout SECSDrop a connection that moves no data and no control message for SECS seconds; the session then reconnects. 0, the default, means no timeout.A connection idle for SECS seconds ends the run with code 30.
--progressDraws the live progress block (see Output) when stdout is a terminal.Prints the progress of each file.
-PThe same as --progress. irsync always keeps partial files.The same as --partial --progress.
--info SPECOnly 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.

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, largest file first; a last line … and N more counts the others. 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. 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. -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.

FlagMeaning
--parallel NData streams a push keeps open at once, across all files. Default: parallel from the host entry, else from [client], else 128. A pull uses the daemon’s 128. See Files in flight and streams.
--reconnect DURHow 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 host entry, else from [client], else 24h. This window applies only once the server has answered; before that, --dial-retries applies.
--dial-retries NHow 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 host entry, else from [client], else 4.
--relay URLUse this relay server instead of the host entry’s, [client]’s or n0’s default. Cannot be combined with --no-relay or --address.
--no-relayDirect connections only: never fall back to a relay. The address lookups stay on. Default: relay_mode from the host entry, else from [client].
--no-dhtDo not look the daemon up in the mainline DHT.
--address ADDRDial the daemon at ip:port, [ipv6]:port or host:port directly; repeatable. Turns the relay, DNS, DHT, mDNS and the port mapper off. The daemon’s EndpointId is still required and still checked.
--config PATHThe config file. Default: ~/.config/irsync/irsync.toml. A hosts.toml or exports.toml beside it is read too.
--rsh CMDThe remote shell for the ssh setup, split on spaces like rsync’s -e, for example --rsh "ssh -p 2222". Default: IRSYNC_RSH, else ssh.
--sshGo through ssh even for a saved host: install or update irsync on the server, check its daemon and the grant, then sync. Uses the host’s ssh destination, else the alias. Default: off; a saved host is reached over iroh only.
--no-remote-dhtWhen setting the server up over ssh, turn its DHT publishing off ([daemon.discovery] dht = false); a running daemon re-reads its settings. Goes through ssh for a saved host too, like --ssh. Without it the server’s setting is left alone, and new servers publish.
--identity FILEThe private key to connect with. Default: 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 PATHRead 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-resumeStart a fresh plan instead of resuming a dormant session. Partial files are still picked up.
--no-rename-detectionDo 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 ADDRServe 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-waitWith --debug-addr, close the port when the sync ends instead of waiting.

The connection settings resolve in this order: the flag, then the host alias’s table, then [client], then the built-in default. See Configuration.

Subcommands

CommandWhat it does
irsync daemonRun the daemon. See below.
irsync indexHash the files under local roots into their index. See Seed the index.
irsync gcRemove abandoned partial files, dormant sessions and stale index entries. See Clean up state.
irsync host, export, grant, id, config, showManage aliases, exports, grants, identities and settings. See Management commands. irsync grant add immediate WHO lets WHO reach any path, read-write; it is what the ssh setup grants.

irsync daemon

irsync daemon [--config PATH] [--passphrase-file PATH] [--listen ADDR]... [-v|-q]

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 info level; -v gives debug, -vv trace, -q errors only, and RUST_LOG overrides all of them.

FlagMeaning
--config PATHThe config file. A hosts.toml or exports.toml beside it is read too.
--passphrase-file PATHRead the passphrase of an encrypted daemon key from the first line of this file.
--listen ADDRBind 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.
-v, --verboseLog more; repeat for more still.
-q, --quietLog errors only.

irsync index

irsync index [-n] [-v|-q] [--config PATH] ROOT...
FlagMeaning
-n, --dry-runWalk and count what would be hashed; read nothing.
-v, --verboseLog more.
-q, --quietLog errors only and print no summary.
--config PATHThe config file, for state_dir.

irsync gc

irsync gc [-n] [-v|-q] [--config PATH]
FlagMeaning
-n, --dry-runList what would be removed without removing anything.
-v, --verboseLog more.
-q, --quietLog errors only and print no summary.
--config PATHThe config file, for state_dir.

Environment

VariableEffect
IRSYNC_PASSPHRASEThe passphrase of an encrypted key, when no --passphrase-file is given.
IRSYNC_RSHThe remote shell for the ssh setup, when no --rsh is given.
RUST_LOGThe log filter, in place of the one -v and -q choose.
OTEL_EXPORTER_OTLP_ENDPOINTExport traces and metrics over OpenTelemetry to this endpoint. Overrides [telemetry] in the config file.
TERMdumb turns the live progress block off.

Exit codes

CodeMeaning
0Success.
1Nothing got through: a configuration, identity or connection error; an operand pair irsync rejects (both sides local, both remote, several sources on a pull); or every source failed.
2The command line could not be parsed: an unknown flag, a bad value, a missing operand.
23Partial transfer: some files could not be transferred, or some sources of a push failed while others synced.
24Some source files vanished. Only --paranoid, in its final re-check, gives this.
25Deletions 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 and irsync export update exit 23 when a file could not be read or a directory could not be listed, and irsync config get exits 1 for a key that is not set and has no default.