Repository navigation
Description
Summary
backupdrill restore fails on any target when the snapshot's manifest records an
extension whose schema is pg_catalog (pg_cron on Supabase, for example). Before
each create extension, installExtensions in dist/restore-engine.js runs
create schema if not exists <schema>. For pg_catalog Postgres rejects that
statement outright, because the pg_ prefix is reserved and the name check runs
before the "if not exists" check. The error is caught and the extension is reported
as unavailable, so restore stops with
target cannot install extension(s): pg_cron — enable them in ..., although
create extension if not exists pg_cron on its own succeeds on the same target.
drill has the same code path but only records the failure
(sandbox extensions — installed 4/7; sandbox image cannot install: pg_cron, ...),
so a drill passes while a restore of the same snapshot cannot.
Versions
- backupdrill 2.1.8 (pinned here) and 2.2.4 (latest),
dist/restore-engine.js,
installExtensions - Node 24
- Target: PostgreSQL 17 (a local Supabase stack; also
reproduced on plain PostgreSQL 17.11) - Source: Supabase, pg_cron 1.6.4 installed in
pg_catalog, as Supabase installs it
Minimal reproduction
The statement the engine issues, on any PostgreSQL:
create schema if not exists "pg_catalog";ERROR: unacceptable schema name "pg_catalog"
DETAIL: The prefix "pg_" is reserved for system schemas.
And the extension install that would have worked:
create extension if not exists pg_cron;works as postgres on a Supabase target (pg_cron must be in
shared_preload_libraries, which it is on Supabase).
End to end: take a backup of a Supabase project that has pg_cron installed
(manifest.json will contain {"name":"pg_cron","version":"1.6.4","schema":"pg_catalog"}),
then backupdrill restore --snapshot <id> into a fresh Supabase project or local
stack. The restore stops before pg_restore:
target cannot install extension(s): pg_cron — enable them in the dashboard first
Expected
The restore installs pg_cron (or any extension whose manifest schema is a system
schema) and proceeds. Or, if the extension is genuinely unavailable on the target,
the message says so with Postgres's own error rather than the schema-creation error
being swallowed as "unavailable".
Actual
create schema if not exists "pg_catalog" throws, the catch in installExtensions
records pg_cron as unavailable, and restore exits 1. The real Postgres error is
never shown.
Where
dist/restore-engine.js, installExtensions (2.1.8 line 300, 2.2.4 line 305):
for (const ext of extensions) {
try {
await client.query(`create schema if not exists ${quoteIdent(ext.schema)}`);
await client.query(`create extension if not exists ${quoteIdent(ext.name)} schema ${quoteIdent(ext.schema)} cascade`);
}
catch {
unavailable.push(ext.name);
}
}The generated RECOVERY.md carries the same shape in its manual SQL
(create extension if not exists "pg_cron" schema "pg_catalog" cascade; after a
schema-creation step), so the documented fallback fails the same way.
Suggested fix
Skip the create schema step when the schema already exists or is a system schema
(pg_catalog, information_schema, anything with the pg_ prefix), for example:
if (!/^pg_/.test(ext.schema) && ext.schema !== "information_schema") {
await client.query(`create schema if not exists ${quoteIdent(ext.schema)}`);
}and surface the underlying error text when an extension cannot be installed, so a
real unavailability and a failed preparatory statement read differently. It would
also help if drill reported which error made an extension "unavailable", for the
same reason.
Workaround we use
create extension if not exists pg_cron; by hand (no schema clause; it lands in
pg_catalog), then the two-pass pg_restore the engine itself runs
(--section=pre-data --section=data --no-owner --no-privileges, then
--section=post-data --no-owner --no-privileges). This recovered 24/24 tables with
matching fingerprints from a 2.1.8 snapshot on 30 September 2026.
Activity