Database

Moving Your Database Between Homes

Take everything (people, clients, findings, files and secrets) from PostgreSQL in your cloud, a self-hosted stack or Supabase Cloud to either of the others, in your own browser, with nothing passing through Pental.

4 min read · Updated

Where your database lives is not a decision you are stuck with. The move copies everything from your current database to a new one in any of the three homes, compares the two table by table, and switches the portal over only when you say so. It runs in your own browser, or on your own computer, with your databases’ own credentials. Nothing passes through Pental.

Before you start

  • The new database, set up as its guide describes: PostgreSQL in your cloud, self-hosted Supabase or Supabase Cloud. The move shows the same steps for it.
  • Each database’s own service credential, which only the move uses (see the next section).
  • A quiet moment: while the copy runs, reading and signing in carry on, but saving pauses.

Where each credential is

HomeThe credential, and where to find it
PostgreSQL in your cloudThe gateway’s setup token (pst_…), from your password manager or beside its deploy script, in the pental-gateway folder: grep ^SETUP_TOKEN= deploy/*/.deploy-*.env deploy/compose/.env on macOS or Linux, Get-ChildItem deploy -Recurse -Force -Filter .deploy-*.env | Select-String ^SETUP_TOKEN= in PowerShell.
Self-hosted SupabaseThe stack’s service key. On its server, in the kit’s folder, grep ^SERVICE_ROLE_KEY= .env prints it.
Supabase CloudThe project’s service_role key (it starts eyJ), under API Keys, then Legacy API keys. Supabase refuses its newer sb_secret_ keys from a browser, so a project with only those moves from your computer instead.

They go from your browser to your own databases and nowhere else, are never sent to Pental, and are dropped when the move ends.

Start the move

  1. On your pental.io dashboard, under Portal Configuration, open Database, and under Move your database press Start a move.
  2. Choose the new home and follow its steps, as at setup. The last one takes its credential: for a Supabase project, its legacy service_role key; for a stack, its service key; for a gateway, its setup token, and Prepare the new gateway applies the setup SQL through it.
  3. Press Next: your current database and paste the current one’s credential.
  4. Press Start the move, and keep the tab open while it runs.

What happens when you press it

  1. Both databases are checked: reachable, on the same setup SQL, and the new one empty (or you are asked before it is replaced).
  2. Saving pauses on the current database. People can keep reading the portal and signing in; anyone saving is told the database is being moved. Saving resumes by itself if the move stops.
  3. Every row, file and sealed secret is copied straight from one database to the other, through your browser.
  4. The two are compared, table by table. A file uploaded meanwhile is caught here, and you are asked to run it again.
  5. You decide: switch the portal to the new database (the old one is then closed, and everyone signs in again on the new one), or cancel and carry on as before.

Stop the move, or cancel at the end, and saving resumes on the current database with everything as it was. The portal switches only when every count matches, unless you choose otherwise.

From your own computer

For a Supabase project whose newer secret key a browser may not use, or a database too large to leave to a browser tab, the same move runs on your own machine, Windows, macOS or Linux. Under Or move from your computer the dashboard writes one paste for your computer, with both addresses in: it downloads pental-move.mjs and runs it with Node.js 18 or later, your computer’s own or, if you say yes, a copy it downloads from nodejs.org for the move alone. The mover asks for both credentials there, without showing them.

Commands for
Windows, in PowerShell
cd ~; curl.exe -fsSLO --retry 3 --retry-all-errors https://pental.io/downloads/pental-move.ps1; if ($?) { powershell -ExecutionPolicy Bypass -File pental-move.ps1 --from https://current-database --to https://new-database }
macOS and Linux, in a terminal
cd ~
curl -fsSL https://pental.io/downloads/pental-move.sh | sh -s -- --from https://current-database --to https://new-database

When it says every count matches, it keeps saving paused and waits. Switch the portal on your dashboard, then type SWITCHED in the terminal to close the old database for good.

Afterwards

The portal now runs on the new database, and everyone signs in again there. The old database refuses changes and tells anyone still on it to reload. Look around, then delete it, or its project, whenever you are ready.


Change Your Mind Whenever You Like

Every portal runs end-to-end encrypted on a database you own, in whichever of the three homes suits you, and moves between them from your dashboard.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, on your own server.


Also Worth Reading

Setup guide

Prefer to watch it?

This step is in the recording as “Moving your database between homes”, from 4:56. Every other step is a chapter away.

  • 4:56 · Moving your database between homes
  • +6 more