Skip to content
LastGood

Help

What Supabase calls Database write

The backup setup asks you to approve an OAuth app. Supabase labels one of those permissions Database write. LastGood uses it to create a separate read-only login for your database, and a storage login for your files. It does not ask for your database password. Adding the storage login runs whatever your app does when a user is added or signs in, such as making a profile row (more below); LastGood changes nothing else in your tables or the rows in them.

Why that permission is needed

Creating a database role is a SQL statement. Supabase does not offer a narrower switch that means “create one read-only user and nothing else”. The switch that can run that SQL is labelled Database write. Database read is separate: it lets LastGood see the Session pooler host. Secrets stay off, so the token cannot read your API keys. Other write scopes stay off.

LastGood runs that SQL while you are on the connect page. The Supabase token sits in an encrypted cookie for up to 15 minutes and is cleared when setup finishes. The refresh token is not stored. LastGood does not keep the Supabase token after that.

What is created

One role, named lastgood_backup, on the project you chose. It can log in. It is granted pg_read_all_data, which is SELECT on tables, views and sequences, and USAGE on schemas, including objects created later. It is also granted CONNECT on the existing postgres database.

LastGood also asks for BYPASSRLS so a backup can read rows that row level security would hide. The backup role does not own your tables, and many policies only return rows to a signed-in app user. The usual Supabase postgres role is allowed to set this attribute. If Supabase refuses it, LastGood creates the role without it, and the backup then stops with an error at the first table with row level security turned on, instead of saving a copy with rows missing.

One user in your Supabase Authentication users, lastgood-backup@lastgood.invalid: the storage login that copies your files. With it come eight storage policies whose names start with lastgood_backup_. Two let that user read every file and bucket. Six stop it adding, changing or deleting a file or bucket, whatever your own policies allow. Supabase gives every signed-in user the authenticated role, so outside storage the login can do whatever your app lets any signed-in user do. Adding it runs anything your app does when a user is added, as a sign-up would. So before making it, the connect page lists what your app runs when a user is added, changed or signs in, by name only: triggers on your users, their identities, sessions and refresh tokens, and the Custom Access Token and Password Verification Attempt Auth Hooks. If there is anything, LastGood makes the login only once you confirm, and you can leave your files out instead. Those run again whenever the login changes or signs in, which your workflow does each night. The login is not counted among your app’s users in the nightly results. Its password is generated, written as the Actions secret LIFEBOAT_STORAGE_LOGIN and discarded, like the role’s. It signs in with your project’s publishable key, which you paste when you connect, because Secrets stay off.

What the dump contains

pg_dump writes a custom-format copy of definitions it can see, including catalogue definitions, and of rows the role can read. That includes auth and storage metadata. With BYPASSRLS, the dump can include password hashes from auth.users and vault rows the grant can see.

The file is encrypted before it is uploaded. Encryption runs on the GitHub Actions runner, to this app’s public key, with age. Only the private key opens it. Unless you turned on strict mode, it is in your repository’s secrets. You also saved it when you connected, as a key file or as shares, any two of which rebuild it. If a copy is changed after it was made, it fails to open instead of restoring wrong data. If GitHub’s copy is gone and you have neither the key file nor two of its shares, that dump cannot be decrypted.

Storage files are not in the dump. Your workflow copies them separately, with the storage login made when you connect. A bucket count or an object name is not the file itself. The monthly test restore uses a throwaway database. Event triggers, publications, objects already in public, and schemas that database already has, such as auth, storage and supabase_realtime, are dropped first and the dump recreates them. Schemas an extension owns, such as graphql and vault, stay. An extension the throwaway database does not offer is left out. An object that still already exists is a warning. A row that fails to load still fails the test. A successful dump is not a promise that every object will restore.

Where the connection string is stored

LastGood generates a password for lastgood_backup, builds the Session pooler URL, and writes it as the GitHub Actions secret DATABASE_URL on your repository. The username looks like lastgood_backup.<project-ref>. That secret lives in GitHub, not on LastGood servers. The role password is discarded as soon as the secret is written. LastGood does not show it and does not store it.

Your browser makes this app’s key on the connect page. The public half is stored as the Actions variable LIFEBOAT_PUBLIC_KEY. The private half is sealed in your browser with GitHub’s own secret encryption and stored as the Actions secret LIFEBOAT_PRIVATE_KEY in the same repository, unless you turn on strict mode. LastGood never sees the private half. It keeps a copy of the public half, which can only lock copies, and, when your key is split into shares, one share locked in a key vault, which opens nothing on its own.

How to revoke it

In Supabase, revoke the LastGood OAuth app for the organisation that approved it. That stops new Management API calls. It does not remove the role, and it does not delete the GitHub secret, so a workflow that already has DATABASE_URL can still connect until you remove those.

To stop the role or drop it, open the Supabase SQL editor for that project and run:

-- Stop the backup user signing in
alter role lastgood_backup nologin;

-- Or remove it completely
revoke connect on database postgres from lastgood_backup;
drop role lastgood_backup;

If Postgres says the role is still in use, disconnect that session and run the statement again. Dropping the role does not delete dumps already stored in the backup destination you chose. Remove DATABASE_URL from the repository’s Actions secrets if you also want the workflow to stop logging in.

To remove the storage login, first delete any rows your app made of its own when lastgood-backup@lastgood.invalid was added, such as a profile row: a table that points at the user without on delete cascade stops the user being deleted. Then delete the user in Authentication users, and drop its storage policies in the SQL editor:

do $$ declare p record; begin
  for p in select policyname, tablename from pg_policies
    where schemaname = 'storage' and policyname like 'lastgood\_backup\_%' loop
    execute format('drop policy %I on storage.%I', p.policyname, p.tablename);
  end loop;
end $$;

To stop the nightly file copy without removing the login, delete the Actions secret LIFEBOAT_STORAGE_LOGIN from the repository. Connecting again without your files leaves that secret where it is.

Back to help