<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How should a bundled-ClickHouse package back up: raw &#x2F;app&#x2F;data snapshot vs logical dump via backupCommand?]]></title><description><![CDATA[<h2>Context</h2>
<p dir="auto">Following on from <a href="https://forum.cloudron.io/topic/15663/backup-task-crashes-when-a-clickhouse-app-deletes-a-temp-merge-dir-mid-snapshot">the backup crash thread</a> (now fixed, thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/girish" aria-label="Profile: girish">@<bdi>girish</bdi></a>), there is a related but separate question on the packaging side where we would like some input.</p>
<p dir="auto">Even with the <code>readTree</code> null guard, backing up a bundled ClickHouse by letting the platform rsync its live store under <code>/app/data</code> can capture an <strong>inconsistent set of parts</strong>. ClickHouse merges in the background throughout the snapshot, and its own guidance is to back up via <code>ALTER TABLE ... FREEZE</code> or <code>clickhouse-backup</code> rather than copying the live data directory, because a raw copy can catch a merge in flight. So the crash is solved, but backup <em>correctness</em> for ClickHouse-bundling packages (Langfuse, Plausible, PostHog, SigNoz) is still worth nailing down.</p>
<h2>The mechanism that looks right</h2>
<p dir="auto">The newer manifest fields (box 9.1.0+) look purpose-built for this:</p>
<ul>
<li><code>persistentDirs</code> keeps a directory out of the filesystem backup entirely.</li>
<li><code>backupCommand</code> runs during backup and is meant to write a portable logical dump into <code>/app/data</code>.</li>
<li><code>restoreCommand</code> runs before the app starts to repopulate from that dump.</li>
</ul>
<p dir="auto">The intended shape for a ClickHouse package would then be:</p>
<pre><code class="language-json">{
  "manifestVersion": 2,
  "minBoxVersion": "9.1.0",
  "addons": { "localstorage": {} },
  "persistentDirs": [ "/var/lib/clickhouse" ],
  "backupCommand": "/app/pkg/backup-clickhouse.sh",
  "restoreCommand": "/app/pkg/restore-clickhouse.sh"
}
</code></pre>
<p dir="auto">The ClickHouse store lives in <code>/var/lib/clickhouse</code> (a persistentDir, so it is never walked by the filesystem backup and never racy), and <code>backup-clickhouse.sh</code> writes a consistent dump into <code>/app/data</code>, which is what actually gets backed up.</p>
<h2>The open question</h2>
<p dir="auto">The documented <code>backupCommand</code> example is <code>pg_dump</code>, which works because PostgreSQL is a shared addon the command can reach over the network. A bundled ClickHouse is different: the docs say <code>backupCommand</code> runs via <code>docker run</code> in a temporary container from the app image, so as far as we can tell, it does not share a network with the running app, and the live ClickHouse server is presumably still running against <code>/var/lib/clickhouse</code> at that moment.</p>
<p dir="auto">That leaves a few unknowns I have not been able to settle from the docs:</p>
<ol>
<li>Is the app quiesced while <code>backupCommand</code> runs, or is the live container still up and writing?</li>
<li>Can the <code>backupCommand</code> container reach the running app (socket or network) to issue a consistent <code>BACKUP</code> or <code>FREEZE</code>? Or is the expectation that it operates purely on the mounted files?</li>
<li>If it operates on the files, what is the intended way to get a consistent export without two servers touching one data directory at once? A <code>FREEZE</code>-based hardlink snapshot into <code>/app/data</code> seems safest, but I would like to confirm the intended pattern before shipping it.</li>
</ol>
<p dir="auto">If anyone has a working <code>backupCommand</code> for a bundled database that is not a Cloudron addon, I would love to see the shape of it. We have a live ClickHouse app under merge load and a throwaway test instance, so are happy to prototype, write it up, and feed a working pattern back to the community packages.</p>
]]></description><link>https://forum.cloudron.io/topic/15681/how-should-a-bundled-clickhouse-package-back-up-raw-app-data-snapshot-vs-logical-dump-via-backupcommand</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 02:35:14 GMT</lastBuildDate><atom:link href="https://forum.cloudron.io/topic/15681.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Jul 2026 09:51:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How should a bundled-ClickHouse package back up: raw &#x2F;app&#x2F;data snapshot vs logical dump via backupCommand? on Mon, 06 Jul 2026 12:18:29 GMT]]></title><description><![CDATA[<p dir="auto">I have fixed the backupCommand to share the networking namespace with the app - <a href="https://git.cloudron.io/platform/box/-/commit/90a8ba1a4915dfbbb30f1073c4f75cd99635ae3d" target="_blank" rel="noopener noreferrer nofollow ugc">https://git.cloudron.io/platform/box/-/commit/90a8ba1a4915dfbbb30f1073c4f75cd99635ae3d</a> . This is consistent with how the scheduler/cron commands also run. Thanks for reporting!</p>
]]></description><link>https://forum.cloudron.io/post/126459</link><guid isPermaLink="true">https://forum.cloudron.io/post/126459</guid><dc:creator><![CDATA[girish]]></dc:creator><pubDate>Mon, 06 Jul 2026 12:18:29 GMT</pubDate></item><item><title><![CDATA[Reply to How should a bundled-ClickHouse package back up: raw &#x2F;app&#x2F;data snapshot vs logical dump via backupCommand? on Mon, 06 Jul 2026 12:03:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/loudlemur" aria-label="Profile: loudlemur">@<bdi>loudlemur</bdi></a> the <code>backupCommand</code> is run in it's own networking and pid namespace. But it does share the filesystem mounts (persistentDirs and /app/data) with the app.</p>
<p dir="auto">Not a clickhouse expert but AI suggests that you can make clickhouse listen in a path like this (along with your any existing network bind):</p>
<pre><code>    &lt;native_socket_path&gt;/var/run/clickhouse-server/clickhouse.sock&lt;/native_socket_path&gt;
    &lt;http_socket_path&gt;/var/run/clickhouse-server/clickhouse-http.sock&lt;/http_socket_path&gt;
</code></pre>
<p dir="auto">You can put <code>/var/run/clickhouse-server</code> as another persistentDir and then the backupCommand will have access to it.</p>
]]></description><link>https://forum.cloudron.io/post/126458</link><guid isPermaLink="true">https://forum.cloudron.io/post/126458</guid><dc:creator><![CDATA[girish]]></dc:creator><pubDate>Mon, 06 Jul 2026 12:03:53 GMT</pubDate></item></channel></rss>