Repository navigation
Expand file tree
/
Copy pathconfiguration.html
More file actions
303 lines (289 loc) · 29.9 KB
/
Copy pathconfiguration.html
File metadata and controls
303 lines (289 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'self'; img-src 'self'; base-uri 'none'; form-action 'none'">
<meta name="description" content="Where settings live, every site and server field, cloaking, the sensitive-file guard and secrets.">
<title>Configuration | cmd-sync-servers</title>
<link rel="stylesheet" href="assets/site.css">
</head>
<body>
<a class="skip" href="#main">Skip to the content</a>
<header class="site-header">
<div class="inner">
<a class="brand" href="index.html">cmd-sync-servers</a>
<nav aria-label="Pages">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="quickstart.html">Quickstart</a></li>
<li><a href="getting-started.html">Getting started</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="cheatsheets.html">Cheatsheets</a></li>
<li><a href="configuration.html" aria-current="page">Configuration</a></li>
<li><a href="cli.html">Command line</a></li>
<li><a href="options.html">Options</a></li>
<li><a href="synchronization.html">Synchronization</a></li>
<li><a href="api.html">Library API</a></li>
<li><a href="security.html">Security</a></li>
<li><a href="troubleshooting.html">Troubleshooting</a></li>
</ul>
</nav>
</div>
</header>
<main id="main">
<h1>Configuration</h1>
<p class="lead">One list of sites, shared by the command line and the VS Code extension, plus per-machine state that never leaves the computer.</p>
<h2 id="folders">Where things are kept</h2>
<p>Settings roam with your user profile; state stays on the machine. <code>sync-servers config path</code> prints the folders in use.</p>
<table>
<caption>Folders per platform</caption>
<thead><tr><th scope="col">Platform</th><th scope="col">Settings (<code>sites.json</code>)</th><th scope="col">State and logs</th></tr></thead>
<tbody>
<tr><td>Windows</td><td><code>%APPDATA%\sync-servers</code></td><td><code>%LOCALAPPDATA%\sync-servers</code>, logs in its <code>logs</code> folder</td></tr>
<tr><td>macOS</td><td><code>~/Library/Application Support/sync-servers</code></td><td>its <code>state</code> folder; logs in <code>~/Library/Logs/sync-servers</code></td></tr>
<tr><td>Linux and other systems</td><td><code>$XDG_CONFIG_HOME/sync-servers</code>, else <code>~/.config/sync-servers</code></td><td><code>$XDG_STATE_HOME/sync-servers</code>, else <code>~/.local/state/sync-servers</code></td></tr>
</tbody>
</table>
<p><code>SYNC_SERVERS_HOME</code> moves both: settings to that folder and state to its <code>state</code> subfolder. <code>--config-dir</code> and <code>--state-dir</code> move one for a single command. Folders are created private to you (<code>0700</code> on Linux and macOS).</p>
<table>
<caption>What the state folder holds</caption>
<thead><tr><th scope="col">Path</th><th scope="col">Holds</th></tr></thead>
<tbody>
<tr><td><code>sites/<site id>/<server id>.json</code></td><td>The sync records: both sides of every file as they were at its last synchronization.</td></tr>
<tr><td><code>sites/<site id>/<server id>.dwsync.json</code></td><td>How Dreamweaver reads that server's clock, once it is known; see <a href="#dreamweaver-clock">The server's clock</a>.</td></tr>
<tr><td><code>sites/<site id>/hashes.json</code></td><td>The scan cache of file hashes, used in checksum mode.</td></tr>
<tr><td><code>recovery/<site id>/<run>/</code></td><td>Local files a run deleted or overwrote, kept 14 days by default.</td></tr>
<tr><td><code>logs/run-*.jsonl</code></td><td>One log per run, the newest 30 kept, with every secret removed.</td></tr>
</tbody>
</table>
<h2 id="sites-json">The list of sites</h2>
<p><code>sites.json</code> is plain JSON, described by a <a href="schema/site.schema.json">JSON Schema</a> that editors use for completion. Every write is atomic, keeps the previous version as <code>sites.json.bak</code>, and takes a lock file so two programs never lose each other's changes. A file that does not validate is never rewritten. Edit it with the commands, the terminal interface, <code>sync-servers site edit --editor</code> for one site, or <code>sync-servers config edit</code> for the whole file. Both reopen your editor with the problems listed until the JSON is valid, and <code>config edit</code> works even when the file does not load.</p>
<pre><code>{
"$schema": "https://isocialpractice.github.io/cmd-sync-servers/schema/site.schema.json",
"schemaVersion": 2,
"cloaking": { "patterns": [".git/", "node_modules/"] },
"sites": [
{
"id": "3f2b7c1e-8a4d-4f6b-9c2e-1d5a7b9e0c31",
"name": "My Site",
"localRoot": "/home/<user>/sites/my-site",
"servers": [
{
"id": "9a1c3e5f-7b2d-4e6a-8c0f-2b4d6e8a0c13",
"name": "Production",
"protocol": "sftp",
"host": "sftp.example.com",
"username": "demo-user",
"auth": { "method": "password", "savePassword": true },
"remoteRoot": "/var/www/my-site",
"webUrl": "https://www.example.com/"
}
],
"remoteServerId": "9a1c3e5f-7b2d-4e6a-8c0f-2b4d6e8a0c13",
"cloaking": { "patterns": [".psd"] }
}
]
}</code></pre>
<p>Fields left out take their defaults. Passwords never appear in this file. <code>schemaVersion</code> is the version of the file format, now 2: a version 1 file is read, written back as version 2 and kept as <code>sites.json.bak</code>, and a build that knows only version 1 refuses a version 2 file with a message to update. At the top, <code>cloaking.patterns</code> holds the <a href="#global-cloaking">global cloaking patterns</a>, which every site uses before its own; it is written only while it holds a pattern.</p>
<h3 id="site-fields">Site fields</h3>
<table>
<caption>Fields of a site</caption>
<thead><tr><th scope="col">Field</th><th scope="col">Default</th><th scope="col">Meaning</th></tr></thead>
<tbody>
<tr><td><code>id</code></td><td>generated</td><td>A random UUID that stays the same when the site is renamed.</td></tr>
<tr><td><code>name</code></td><td></td><td>The name you know the site by; unique, ignoring case.</td></tr>
<tr><td><code>localRoot</code></td><td></td><td>The local site folder, an absolute path.</td></tr>
<tr><td><code>servers</code></td><td><code>[]</code></td><td>The site's servers, described below.</td></tr>
<tr><td><code>remoteServerId</code></td><td>the first server</td><td>The server synchronization uses.</td></tr>
<tr><td><code>testingServerId</code></td><td>none</td><td>The server automatic pushes go to, such as the extension's upload on save.</td></tr>
<tr><td><code>local.webUrl</code></td><td>none</td><td>The local web address, such as <code>http://localhost:8080/</code>.</td></tr>
<tr><td><code>local.caseSensitive</code></td><td>probed</td><td>Whether local names differ by case. Unset: the file system is asked.</td></tr>
<tr><td><code>local.cache</code></td><td><code>true</code></td><td>Keep file hashes between runs in checksum mode.</td></tr>
<tr><td><code>cloaking.enabled</code></td><td><code>true</code></td><td>Turns cloaking on or off, keeping the patterns. Off also turns off the global patterns for the site.</td></tr>
<tr><td><code>cloaking.useGlobalPatterns</code></td><td><code>true</code></td><td>Use the <a href="#global-cloaking">global patterns</a> before the site's own. Written only when <code>false</code>.</td></tr>
<tr><td><code>cloaking.patterns</code></td><td><code>[]</code></td><td>Cloaking patterns; see <a href="#cloaking">Cloaking</a>.</td></tr>
<tr><td><code>cloaking.paths</code></td><td><code>[]</code></td><td>Site-relative files and folders cloaked one by one.</td></tr>
<tr><td><code>sync.maintainInfo</code></td><td><code>true</code></td><td>Keep sync records, so a change on both sides is detected.</td></tr>
<tr><td><code>sync.dreamweaver.enabled</code></td><td><code>false</code></td><td>Read and update the synchronization records Dreamweaver keeps in each folder of a site as <code>_notes/dwsync.xml</code>; see <a href="#dreamweaver">Dreamweaver synchronization files</a>. Needs <code>sync.maintainInfo</code>.</td></tr>
<tr><td><code>sync.compare</code></td><td><code>metadata</code></td><td><code>metadata</code> compares size and time; <code>checksum</code> also compares SHA-256 hashes where both are known.</td></tr>
<tr><td><code>sync.mtimeToleranceSeconds</code></td><td><code>2</code></td><td>Times this close count as equal, for servers that round them.</td></tr>
<tr><td><code>sync.symlinks</code></td><td><code>skip</code></td><td>Which symbolic links in the local folder are followed: none (<code>skip</code>), those inside the site (<code>follow-inside-root</code>) or all (<code>follow</code>); see <a href="#links">Symbolic links</a>.</td></tr>
<tr><td><code>sync.concurrency</code></td><td><code>4</code></td><td>Transfers at once, from 1 to 16.</td></tr>
<tr><td><code>sync.guard.enabled</code></td><td><code>true</code></td><td>Hold back sensitive files; see <a href="#guard">The sensitive-file guard</a>.</td></tr>
<tr><td><code>sync.guard.patterns</code></td><td><code>[]</code></td><td>More patterns to hold back, added to the built-in list.</td></tr>
<tr><td><code>sync.massDelete.maxCount</code></td><td><code>50</code></td><td>Deleting more files than this asks you to type the count.</td></tr>
<tr><td><code>sync.massDelete.maxPercent</code></td><td><code>25</code></td><td>Deleting more than this share of a side's files asks too.</td></tr>
<tr><td><code>sync.recovery.enabled</code></td><td><code>true</code></td><td>Keep local files that a run deletes or overwrites.</td></tr>
<tr><td><code>sync.recovery.keepDays</code></td><td><code>14</code></td><td>How long they are kept.</td></tr>
<tr><td><code>sync.recovery.maxMegabytes</code></td><td><code>1024</code></td><td>The most the recovery folder of a site may hold; the oldest runs go first.</td></tr>
</tbody>
</table>
<h3 id="server-fields">Server fields</h3>
<table>
<caption>Fields of a server</caption>
<thead><tr><th scope="col">Field</th><th scope="col">Default</th><th scope="col">Meaning</th></tr></thead>
<tbody>
<tr><td><code>id</code></td><td>generated</td><td>A random UUID that stays the same when the server is renamed.</td></tr>
<tr><td><code>name</code></td><td></td><td>Unique within the site, ignoring case.</td></tr>
<tr><td><code>protocol</code></td><td></td><td><code>sftp</code>, <code>ftps</code>, <code>ftps-implicit</code>, <code>ftp</code> or <code>local</code>.</td></tr>
<tr><td><code>host</code></td><td></td><td>The host name or IP address alone, such as <code>sftp.example.com</code> or <code>203.0.113.10</code>. A port, a user or a protocol in it, such as <code>server1.hosting.example.net:2083</code>, is refused with the field to use instead. Not used by <code>local</code>.</td></tr>
<tr><td><code>port</code></td><td>22, 21 or 990</td><td>22 for SFTP, 21 for FTP and explicit FTPS, 990 for implicit FTPS.</td></tr>
<tr><td><code>username</code></td><td></td><td>The account to sign in as.</td></tr>
<tr><td><code>auth.method</code></td><td><code>password</code></td><td><code>password</code>, or for SFTP <code>key</code> or <code>agent</code>.</td></tr>
<tr><td><code>auth.keyPath</code></td><td></td><td>The private key file of the <code>key</code> method; read when connecting, never copied.</td></tr>
<tr><td><code>auth.savePassword</code></td><td><code>false</code></td><td>Keep the password or key passphrase in the credential store.</td></tr>
<tr><td><code>remoteRoot</code></td><td></td><td>The site folder on the server, starting with <code>/</code>, as the account sees it; for <code>local</code>, an absolute or network path. Many hosting accounts open in their own folder and see it as <code>/</code>, so a path from a control panel, such as <code>/home/<user>/example.com/my-site</code>, does not exist for them. <code>sync-servers server test</code> shows the folder the account opens in, and a root that is not found names it and what it holds.</td></tr>
<tr><td><code>webUrl</code></td><td>none</td><td>The address of the site on this server.</td></tr>
<tr><td><code>options.timeoutSeconds</code></td><td><code>30</code></td><td>How long a connection or an operation may wait.</td></tr>
<tr><td><code>options.ipFamily</code></td><td>either</td><td><code>4</code> or <code>6</code> to use one IP version only.</td></tr>
<tr><td><code>options.passive</code></td><td><code>true</code></td><td>FTP passive mode; active mode is not supported.</td></tr>
<tr><td><code>options.allowInsecure</code></td><td></td><td>Required for plain <code>ftp</code>, which sends the password in clear text.</td></tr>
<tr><td><code>options.allowRootDeletes</code></td><td></td><td>Allow deletes when the root directory is <code>/</code> or a drive root.</td></tr>
<tr><td><code>options.legacyAlgorithms</code></td><td></td><td>SFTP: also offer older algorithms for an old server, with a warning on every connection.</td></tr>
<tr><td><code>options.tls.caFile</code></td><td></td><td>FTPS: a PEM file of extra certificate authorities, for a private CA.</td></tr>
<tr><td><code>options.tls.servername</code></td><td></td><td>FTPS: the name to verify the certificate against, when it differs from <code>host</code>.</td></tr>
<tr><td><code>options.tls.minVersion</code></td><td><code>TLSv1.2</code></td><td>FTPS: the lowest TLS version accepted.</td></tr>
<tr><td><code>options.tls.trustedCertificate</code></td><td></td><td>FTPS: a certificate you chose to trust after it failed verification: <code>sha256</code> (colon-separated hex), <code>validTo</code> and <code>pinnedAt</code>. Normal verification runs first; an expired certificate is never trusted. Set when you trust a certificate in a terminal; removed with <code>--forget-certificate</code>. See <a href="security.html#certificates">Certificates</a>.</td></tr>
<tr><td><code>options.hostKey</code></td><td></td><td>SFTP: the pinned host key, set when you trust it on first connection.</td></tr>
<tr><td><code>options.uploadOnSave</code></td><td><code>false</code></td><td>Used by the VS Code extension: put a file when it is saved.</td></tr>
<tr><td><code>options.dreamweaverServer</code></td><td>built</td><td>The name Dreamweaver gives this server in <code>_notes/dwsync.xml</code>, such as <code>203.0.113.10//public_html/</code>. Unset: the host, <code>/</code>, and the remote root ending in <code>/</code>, such as <code>sftp.example.com//var/www/my-site/</code>; for <code>local</code>, the folder with <code>/</code> between its parts and at its end. See <a href="#dreamweaver-server">The name Dreamweaver gives a server</a>.</td></tr>
<tr><td><code>options.remoteFileMode</code></td><td>server default</td><td>An octal mode such as <code>644</code> for uploaded files.</td></tr>
<tr><td><code>options.remoteDirMode</code></td><td>server default</td><td>An octal mode such as <code>755</code> for new folders.</td></tr>
</tbody>
</table>
<h2 id="cloaking">Cloaking</h2>
<p>Cloaked files and folders are never scanned, listed, transferred or deleted, on either side. Patterns use the rules of <code>.gitignore</code> files, with one addition for suffixes:</p>
<table>
<caption>Cloaking patterns</caption>
<thead><tr><th scope="col">Pattern</th><th scope="col">Cloaks</th></tr></thead>
<tbody>
<tr><td><code>.psd</code></td><td>Every name ending in <code>.psd</code>: a token that starts with a dot and has no <code>*</code> or <code>/</code> is a suffix.</td></tr>
<tr><td><code>archive*</code></td><td>Every file or folder whose name starts with <code>archive</code>, at any depth.</td></tr>
<tr><td><code>node_modules/</code></td><td>Every folder named <code>node_modules</code>, and everything in it.</td></tr>
<tr><td><code>/drafts/</code></td><td>Only the <code>drafts</code> folder at the top of the site.</td></tr>
<tr><td><code>!keep.psd</code></td><td>Uncloaks what an earlier pattern cloaked.</td></tr>
</tbody>
</table>
<p>Names are matched ignoring case on Windows and macOS. Single paths can be cloaked too, and cloak everything beneath them:</p>
<pre><code>sync-servers cloak .psd "archive*" node_modules/ # patterns
sync-servers cloak img/raw # an existing path in the site
sync-servers cloak --list
sync-servers uncloak .psd</code></pre>
<h3 id="global-cloaking">Global patterns</h3>
<p>Files that belong to no site, such as version control folders, installed packages and the files an operating system leaves behind, can be cloaked once for every site. Every site uses the global patterns before its own, so a site's <code>!pattern</code> re-includes what a global pattern cloaks, and a pattern that starts with <code>/</code> is anchored at each site's local root. Turning cloaking off for a site turns the global patterns off there too.</p>
<pre><code>sync-servers cloak --global .git/ .github/ node_modules/ .DS_Store Thumbs.db desktop.ini "*.lnk"
sync-servers cloak --global # list them
sync-servers uncloak --global .github/
sync-servers cloak --site "My Site" --ignore-global # one site stops using them
sync-servers cloak --site "My Site" --use-global # and uses them again</code></pre>
<p>No global pattern is built in. The list above is a starting point for a typical web site; keep only what your sites never publish. In the terminal interface, <kbd>c</kbd> on the Sites screen edits the global patterns, and Site Setup's Cloaking category shows them beside a Use global patterns switch.</p>
<h2 id="guard">The sensitive-file guard</h2>
<p>Some files are almost never meant to be published. A file matching one of these patterns is listed in the preview <strong>unchecked</strong> with the pattern it matched, and moves only when you check it. It is never hidden.</p>
<pre><code>.env .env.* *.pem *.key *.p12 *.pfx *.kdbx id_rsa* id_ecdsa* id_ed25519*
.git/ .hg/ .svn/ .ssh/ .aws/ .npmrc .pypirc .netrc *.sqlite-journal</code></pre>
<p>Add patterns of your own in <code>sync.guard.patterns</code> or the Security category of Site Setup. Unattended runs with <code>--yes</code> never transfer a guarded file.</p>
<h2 id="links">Symbolic links</h2>
<p>A site's local folder can hold symbolic links and, on Windows, junctions. <code>sync.symlinks</code> says which of them the site follows. Set it with <code>sync-servers site edit --symlinks</code>, in the Synchronization category of Site Setup, or with <code>sync-servers config edit</code>.</p>
<table>
<caption>Values of sync.symlinks</caption>
<thead><tr><th scope="col">Value</th><th scope="col">Follows</th></tr></thead>
<tbody>
<tr><td><code>skip</code> (default)</td><td>No link. Each one is listed as a problem, and nothing is read or written through it.</td></tr>
<tr><td><code>follow-inside-root</code></td><td>Links that lead to a place inside the site's folder.</td></tr>
<tr><td><code>follow</code></td><td>Every link, including links to files and folders outside the site's folder.</td></tr>
</tbody>
</table>
<p>A followed link is synchronized as what it points to, so the server gets ordinary files and folders, never a link:</p>
<ul>
<li>A file link is a file at the link's path. A Put sends the file it points to; a Get writes that file and keeps the link.</li>
<li>A folder link is a folder whose files are listed under the link's path. A file inside it is a file of the folder the link points to, so a Get or a delete changes it there.</li>
<li>A local delete of a path that is itself a link removes the link, never what it points to, and the recovery folder keeps a copy of the content.</li>
<li>A folder that is a link is never removed when a delete leaves it empty.</li>
<li>Two names for one file, such as a link and the file it points to, are two paths of the site. Both are put, and a Get through one changes the other, which the next sync puts too. Rows on one file run one at a time.</li>
<li>Cloaking and the guard see through links: a link to a cloaked file or folder is cloaked, and a link to a file such as <code>.env</code> is held back like the file.</li>
</ul>
<p>Never followed: links on the server, links to something that does not exist, links back into a folder above them, and, with <code>follow-inside-root</code>, links that lead out of the site. Each is a problem row that says why; see <a href="troubleshooting.html#links">Link problems</a>.</p>
<p>With <code>follow</code>, a Get or a delete through a link that leads out of the site changes a file outside the site's folder, and the preview says so on each such row. A link to a large folder makes every scan read all of it, so cloak what the site does not need. A local root that is itself a link is followed with every value.</p>
<p>On Windows, junctions and symbolic links both count. Creating a junction needs no privilege; creating a file symbolic link needs Developer Mode or an administrator. Shortcuts (<code>.lnk</code> files) are ordinary files, not links. In <code>cmd.exe</code>, from the site's folder:</p>
<pre><code>mklink /J fonts C:\Users\<user>\Shared\fonts
mklink css\theme.css C:\Users\<user>\Shared\theme\theme.css</code></pre>
<p>On macOS and Linux:</p>
<pre><code>ln -s ~/shared/fonts fonts
ln -s ~/shared/theme/theme.css css/theme.css</code></pre>
<h2 id="dreamweaver">Dreamweaver synchronization files</h2>
<p>Dreamweaver keeps its synchronization records beside the files they describe. Every folder of a site holds a <code>_notes</code> folder with a <code>dwsync.xml</code> in it, and that file has one entry for each file of the folder and each server, with the time of the local copy and of the server copy at their last transfer:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="index.html" server="203.0.113.10//public_html/" local="134129604153427891" remote="134129604600000000" Dst="1" />
<file name="index.html" server="D:/Sites/my-site-testing/" local="134129604153427891" remote="134129604150000000" Dst="1" />
<file name="about.html" server="203.0.113.10//public_html/" local="133966144428615532" remote="133966144800000000" Dst="2" />
</dwsync></code></pre>
<p><code>sync.dreamweaver.enabled</code> makes a site read and update those files, so a site that was synchronized with Dreamweaver is in sync from its first preview, and both programs go on agreeing. It is off unless it is turned on. <code>sync-servers site add</code> turns it on when the folder holds such records, after asking in a terminal. For a site added earlier, use <code>sync-servers site edit --dreamweaver</code>, the Synchronization category of Site Setup, or <code>sync-servers config edit</code>. <code>sync-servers site show</code> says whether it is on, and whether a site that has it off holds records.</p>
<p>With the setting on:</p>
<ul>
<li>An entry is evidence for a file both sides have. Both copies as the entry says: the file is in sync. One copy as the entry says, and no record of sync-servers itself: the other side changed.</li>
<li>After each transfer the file's entry is written the way Dreamweaver writes it, and a delete removes it. Entries of other servers, and anything in an entry sync-servers does not know, stay as they were.</li>
<li>A site turned on later has its entries written once, from the records sync-servers already keeps.</li>
</ul>
<p>It never does these:</p>
<ul>
<li>Transfer <code>_notes/dwsync.xml</code>. No synchronization lists that file, on either side, with the setting on or off.</li>
<li>Check a delete. A file that is missing on one side is never judged by an entry.</li>
<li>Delete the files when the setting is turned off. They stay as they are, and go out of date.</li>
<li>Use or rewrite a file it does not understand in full, or one behind a link the site does not follow.</li>
</ul>
<p>The setting needs <code>sync.maintainInfo</code>. The records of sync-servers itself stay in the state folder and stay the ones it trusts, so removing a <code>_notes</code> folder loses nothing here.</p>
<h3 id="dreamweaver-server">The name Dreamweaver gives a server</h3>
<p>Each entry names its server the way Dreamweaver does: the host as it was typed there, a <code>/</code>, and the folder on the server ending in <code>/</code>; for a local or network folder, the folder itself. sync-servers builds the same name from a server's host and remote root:</p>
<table>
<caption>Names built for a server</caption>
<thead><tr><th scope="col">Server</th><th scope="col">Name</th></tr></thead>
<tbody>
<tr><td><code>sftp.example.com</code> with the remote root <code>/var/www/my-site</code></td><td><code>sftp.example.com//var/www/my-site/</code></td></tr>
<tr><td>A <code>local</code> server at <code>D:\Sites\my-site-testing</code></td><td><code>D:/Sites/my-site-testing/</code></td></tr>
</tbody>
</table>
<p>Dreamweaver may have known the server by another address or another spelling of the folder, such as an IP address where sync-servers has the host name a certificate covers. Then set the name it used in <code>options.dreamweaverServer</code>: with <code>sync-servers server edit Production --dreamweaver-server 203.0.113.10//public_html/</code>, or in the Advanced tab of the server editor. <code>--dreamweaver-server auto</code> goes back to the built name. Setup lists the names found in the folder and asks which one the server is when the built one matches none. Names are compared without regard to case or a final <code>/</code>.</p>
<h3 id="dreamweaver-clock">The server's clock</h3>
<p>Dreamweaver reads a server's clock its own way: to the minute for FTP, and often some hours from what the server reports to sync-servers. The difference is the same for every file of one server, so sync-servers learns it from the entries, during the first synchronization of the whole site. It needs at least three files whose local copy is the one Dreamweaver recorded and whose server times agree. It then keeps the difference in the state folder, and accepts one hour either way for daylight time.</p>
<p>Until the clock is known, the records of that server are neither used nor written, and <code>sync-servers status</code> says so. <code>sync-servers state reset</code> forgets it together with the sync records; with <code>--dreamweaver</code> it also removes that server's entries from every <code>dwsync.xml</code> of the site.</p>
<p>For a server Dreamweaver never synchronized the folder with, there is nothing to learn from. sync-servers then writes the entries on its own reading of the clock, and Dreamweaver may list those files as changed once.</p>
<h2 id="secrets">Secrets</h2>
<p>Passwords and key passphrases are never written to a file. When a connection needs one, it is looked for in this order:</p>
<ol>
<li>The operating system's credential store, when the server has <code>savePassword</code> on: Windows Credential Manager, the macOS Keychain, or the Secret Service keyring on Linux. Entries use the service <code>sync-servers</code>.</li>
<li>The environment: <code>SYNC_SERVERS_PASSWORD</code>, or <code>SYNC_SERVERS_KEY_PASSPHRASE</code> for a key.</li>
<li>A question in the terminal, typed without being shown. With nobody to ask, the run fails with <code>E_AUTH</code>.</li>
</ol>
<pre><code>sync-servers password set Production --site "My Site" # save it
printf %s "$SECRET" | sync-servers password set Production --stdin
sync-servers password forget Production # remove it</code></pre>
<p>A secret is asked for only after the server's host key or TLS certificate has been verified, and it is removed from every log and error message. A saved secret is tied to the protocol, address, port and user it was saved for; after any of them changes, it is no longer sent and you are asked again, so save it again with <code>password set</code>. <code>SYNC_SERVERS_KEYRING=off</code> turns the credential store off.</p>
<h2 id="environment">Environment variables</h2>
<table>
<caption>Variables sync-servers reads</caption>
<thead><tr><th scope="col">Variable</th><th scope="col">Does</th></tr></thead>
<tbody>
<tr><td><code>SYNC_SERVERS_HOME</code></td><td>Moves the settings and state folders.</td></tr>
<tr><td><code>SYNC_SERVERS_SITE</code></td><td>The site to use when a command names none.</td></tr>
<tr><td><code>SYNC_SERVERS_PASSWORD</code></td><td>The password of the server in use, for unattended runs.</td></tr>
<tr><td><code>SYNC_SERVERS_KEY_PASSPHRASE</code></td><td>The private key passphrase of the server in use.</td></tr>
<tr><td><code>SYNC_SERVERS_KEYRING</code></td><td><code>off</code> turns the operating system's credential store off.</td></tr>
<tr><td><code>SYNC_SERVERS_UI</code></td><td>How previews are shown: <code>tui</code>, <code>editor</code>, <code>plain</code> or <code>none</code>.</td></tr>
<tr><td><code>SYNC_SERVERS_EDITOR</code>, <code>VISUAL</code>, <code>EDITOR</code></td><td>The editor for editor mode and <code>--editor</code>, the first one set. Otherwise Notepad on Windows, then <code>nano</code> or <code>vi</code>.</td></tr>
<tr><td><code>SSH_AUTH_SOCK</code></td><td>The SSH agent for the <code>agent</code> sign-in method. On Windows the OpenSSH agent is used when it is unset.</td></tr>
<tr><td><code>NO_COLOR</code></td><td>Turns colour off; nothing depends on colour.</td></tr>
<tr><td><code>TERM=dumb</code></td><td>Uses ASCII symbols and plain prompts.</td></tr>
</tbody>
</table>
<h2 id="which-site">Which site a command means</h2>
<p>A command acts on the site named by its argument or <code>--site</code>, then <code>SYNC_SERVERS_SITE</code>, then the site whose local folder holds the current folder (the deepest one when sites are nested). In a terminal, you are otherwise asked to choose; in a script, the command stops with a usage error that lists the sites.</p>
</main>
<footer class="site-footer">
<div class="inner">
<p>cmd-sync-servers is open source under the MIT license. Source, issues and releases are on <a href="https://github.com/isocialPractice/cmd-sync-servers">GitHub</a>.</p>
</div>
</footer>
</body>
</html>