App-FileSync
view release on metacpan or search on metacpan
website/html/how-it-works.html view on Meta::CPAN
<code>--snapshot-mode</code>. Fourteen are kept by default.</p>
<p>A hard-linked snapshot shares the file with the live tree. The sync replaces
files by rename, which leaves the snapshot's link intact, but any other tool
that edits a replica file in place also changes every snapshot that links it.
Use <code>snapshot_mode copy</code> if anything but filesync writes there.</p>
<p>Snapshots guard against a bad sync, not against losing the disk: they sit on
the same filesystem as the replica.</p>
<h2 id="layout">On-disk layout</h2>
<h3>On the client</h3>
<div class="table-wrap">
<table>
<thead><tr><th>Path</th><th>Holds</th></tr></thead>
<tbody>
<tr><td><code>~/.filesync/config.json</code></td><td>The repo list, written by <code>filesync init</code>. <code>$FILESYNC_CONFIG</code> overrides the path, <code>$FILESYNC_HOME</code> the directory.</td></tr>
<tr><td><code>~/.filesync/logs/REPO.jsonl</code></td><td>One JSON object per run attempt, successful or not.</td></tr>
<tr><td><code>~/.filesync/</code></td><td>The cache, the per-repo lock and the local trash as well.</td></tr>
<tr><td><code>ROOT/.filesync-root</code></td><td>The marker that proves the sync root is mounted and is the tree the client registered.</td></tr>
</tbody>
</table>
</div>
<h3>On the server</h3>
<div class="table-wrap">
<table>
<thead><tr><th>Path</th><th>Holds</th></tr></thead>
<tbody>
<tr><td><code>ROOT/master/REPO/</code></td><td>The master tree, an ordinary directory.</td></tr>
<tr><td><code>ROOT/.filesync/repos/REPO/config.json</code></td><td>The repo policy and the admitted clients.</td></tr>
<tr><td><code>ROOT/.filesync/repos/REPO/</code></td><td>The index, the per-client bases, the server trash and the journal.</td></tr>
</tbody>
</table>
</div>
<p>The master is a normal tree, so backup is rsync and restore is rsync plus
<code>filesync-admin reindex</code>. The index is a JSON file rewritten whole
at the end of each session.</p>
<h2 id="locking">Locking and concurrency</h2>
<p>Both the client and the server take locks, and a refusal is not an error:
<code>filesync</code> exits <strong>2</strong> so cron can tell "a run was
already in progress" from "a run failed". The plan is computed once, from a
scan taken while the repo lock is held; something else writing into the master
during a session is not seen until the next one.</p>
<p><code>flock</code> is advisory and, on NFS, may not lock across machines at
all. Keep the server root and the client's <code>~/.filesync</code> on local
disks.</p>
<h2 id="security">Security model</h2>
<ul>
<li><strong>Authentication is ssh's.</strong> The client id is a name for
bases, journals and conflict copies, not a credential. ssh runs with
<code>BatchMode=yes</code>, so cron cannot sit at a password prompt.</li>
<li><strong>The server pins the session.</strong> sshd starts
<code>filesync-server</code> with <code>--repo</code>, <code>--client</code>
and <code>--role</code> from <code>authorized_keys</code>. An ssh server of
the form <code>-v@host</code>, or a program name starting with <code>-</code>,
is refused rather than passed to ssh as an option.</li>
<li><strong>Ids are plain.</strong> A repo or client name must match
<code>[A-Za-z0-9][A-Za-z0-9._-]*</code> and be at most 64 characters, so
<code>../x</code> cannot become a path.</li>
<li><strong>Paths are validated on the wire.</strong> No absolute paths,
drive letters, backslashes, NUL or control characters, empty or
<code>.</code>/<code>..</code> components; at most 4096 bytes, and no
component over 255. Symlinks are not followed.</li>
<li><strong>Frames are bounded.</strong> A payload length must be a number no
larger than 64 MiB, and the receiver refuses a frame that does not match
it. An upload larger than announced is refused and discarded.</li>
<li><strong>Errors carry no file paths by default.</strong> Commands strip
Perl's <code>at FILE line N</code> suffix; <code>FILESYNC_TRACE=1</code>
turns every error into a full stack trace when debugging.</li>
</ul>
</main>
<footer class="site-footer">
<div class="wrap">
<p>App::FileSync 0.003.1 · Copyright 2026 Nigel Horne · GPL-2.0</p>
<p><a href="https://metacpan.org/dist/App-FileSync">CPAN</a> ·
<a href="https://github.com/nigelhorne/App-FileSync">GitHub</a> ·
<a href="https://github.com/nigelhorne/App-FileSync/issues">Issues</a> ·
<a href="changelog.html">Changes</a></p>
</div>
</footer>
</body>
</html>
( run in 2.468 seconds using v1.01-cache-2.11-cpan-f5f21f1076c )