Skip to content

Self-hosting

Move from your local Supabase to Supabase Cloud

Started with npm run setup:local? Create a Supabase Cloud project, push the migrations, copy your data (accounts included), files and Vault secrets across, point the app at the cloud, deploy it somewhere public, set the Supabase sign-in URLs and check it.

Last updated 10 min read Edit this page on GitHub
On this page

You started with npm run setup:local: UserTasks and a local Supabase, both on your computer. This page moves you to a real setup: the database, sign-in and files in a Supabase Cloud project, and the app on a server your team can reach.

It takes about an hour. Bringing your data across is optional: skip step 3 for a fresh start.

The commands run from the UserTasks folder on your computer, with the local Supabase still running (npx supabase start). your-project-ref, tasks.yourcompany.com and the passwords are examples: use your own.

1. Create a Supabase project#

  1. Sign up at supabase.com and create a new project.
  2. Pick the region closest to your users (and to the server you'll run the app on: every page makes several database calls).
  3. Choose a strong database password and save it in your password manager. You need it in steps 2 and 3, and Supabase can't show it again (you can only reset it).
  4. When the project is ready, collect four things from the dashboard. Supabase moves these around from time to time, so look for these names:
    • Project ref: the short id in the dashboard's address (supabase.com/dashboard/project/your-project-ref) and in Project Settings.
    • Project URL: https://your-project-ref.supabase.co, under Project Settings (API or Data API).
    • The anon (publishable) key and the service_role (secret) key, under Project Settings → API Keys. If you see both new-style keys and legacy anon and service_role keys, the legacy ones are the same kind that npx supabase status printed for your local stack.
    • The database connection string, from the Connect button at the top of the dashboard. Use the Session pooler string if your network has no IPv6: the direct connection is IPv6-only unless you add Supabase's IPv4 add-on.

Keep the service_role key and the database password secret: either one gives full access to the project.

2. Build the database in the cloud#

Log in to Supabase, link this folder to the project (it asks for the database password), and apply UserTasks' migrations (supabase/migrations):

Bash
npx supabase login
npx supabase link --project-ref your-project-ref
npx supabase db push --linked --dry-run
npx supabase db push --linked

The --dry-run lists the migrations it would apply without changing anything. The last command applies them. The project now has every table, the storage buckets and the pg_cron jobs, but no workspaces or users yet.

Starting fresh? Skip step 3. After step 4, open the app, and the first visit sends you to /setup to create your admin account.

3. Bring your data across (optional)#

UserTasks' own provider switch (usertasks-admin switch database) moves a Supabase install to plain PostgreSQL, not to another Supabase project: for that it says to use a Supabase dump and restore, which is what this step does. You'll copy the database rows (including people and their passwords), then the files.

You need psql, the PostgreSQL command-line client. On macOS: brew install libpq, then follow its note to add it to your PATH. On Ubuntu or Debian: sudo apt install postgresql-client.

Back up first#

Keep a full copy of the local database, in case anything goes wrong:

Bash
mkdir -p backups
npx supabase db dump --local -f backups/local-schema.sql
npx supabase db dump --local --data-only --use-copy -f backups/local-all-data.sql

A practice run is worth it: do steps 2 and 3 into a throwaway Supabase project first, check the app against it, then delete it and do it for real.

Copy the database rows#

  1. Dump your data. Only the schemas UserTasks owns, plus auth (accounts, password hashes and sign-in identities):
Bash
npx supabase db dump --local --data-only --use-copy -s auth,public,app_auth,app_cache,app_cron,app_events,app_kms,app_realtime,app_switch -f backups/local-data.sql

Left out on purpose: storage (the files' records: the upload in the next part creates them), cron (the migrations already created the jobs in the cloud), and vault (secrets, which you set again in step 4). Newer versions of UserTasks may add schemas: list yours with psql 'postgresql://postgres:postgres@127.0.0.1:54322/postgres' -Atc "select nspname from pg_namespace where nspname like 'app%'" and add any missing app_ schema to -s.

  1. Clear the rows the migrations created in the cloud database. Your dump has its own copy of each, and restoring on top of them fails with "duplicate key value violates unique constraint". Use your connection string from step 1, in single quotes:
Bash
psql 'postgresql://postgres.your-project-ref:YOUR-DB-PASSWORD@aws-0-us-east-1.pooler.supabase.com:5432/postgres' -v ON_ERROR_STOP=1 -c "delete from public.oauth_clients; delete from app_realtime.listener_state; delete from app_cron.housekeeping_runs;"

These hold the CLI's built-in OAuth client, a realtime bookmark and the housekeeping history; your dump brings back the CLI client and any OAuth apps you added.

  1. Restore it, all in one transaction, so a failure leaves the cloud database as it was:
Bash
psql 'postgresql://postgres.your-project-ref:YOUR-DB-PASSWORD@aws-0-us-east-1.pooler.supabase.com:5432/postgres' -v ON_ERROR_STOP=1 --single-transaction -f backups/local-data.sql

The dump starts with SET session_replication_role = replica, which pauses triggers and foreign-key checks while the rows go in, so the order of the tables doesn't matter.

People keep their passwords, because the password hashes come across in auth. Everyone signs in again once: the cloud project signs sessions with a different key.

Copy the files#

Uploads, logos, fonts and form files live in Supabase Storage buckets. The migrations created the same buckets in the cloud project. Download each bucket from the local stack, then upload it to the cloud:

Bash
npx supabase storage ls --experimental --local ss:///
npx supabase storage cp --experimental --local -r ss:///logos storage-backup/logos
npx supabase storage cp --experimental --linked -r storage-backup/logos ss:///logos

The first command lists the buckets (task-files, logos, brand-fonts, job-results, gallery-community, form-files). Repeat the two cp lines for each one that has files, changing logos in both places. The upload keeps each file's path, so the links stored in your data keep working. Supabase's S3-compatible API with a tool such as rclone also works for large amounts of files.

With Supabase Storage, UserTasks saves each file's full public address in the data, such as http://127.0.0.1:54321/storage/v1/object/public/… on your laptop. Those addresses came across in step 3 and still point at your computer. Save this as fix-storage-urls.sql, put your project ref in new_base (and use http://localhost:54321/storage/v1/ as old_base if that's what your .env.local had):

fix-storage-urls.sqlSQL
SET session_replication_role = replica;
DO $$
DECLARE
  old_base text := 'http://127.0.0.1:54321/storage/v1/';
  new_base text := 'https://your-project-ref.supabase.co/storage/v1/';
  c record;
  n bigint;
BEGIN
  FOR c IN SELECT * FROM (VALUES
    ('tenants', 'branding'), ('workspace_themes', 'theme'), ('integrations', 'config'),
    ('integration_references', 'request_config'), ('custom_table_rows', 'data'),
    ('workflows', 'nodes'), ('workflow_versions', 'nodes'), ('workflow_runs', 'node_results'),
    ('workflow_runs', 'pause_variables'), ('workflow_runs', 'execution_trace'),
    ('workflow_queue', 'result'), ('workflow_queue', 'trigger_data'), ('tasks', 'metadata'),
    ('agent_runs', 'outputs'), ('agent_runs', 'context')
  ) AS t(tbl, col) LOOP
    EXECUTE format('UPDATE public.%I SET %I = replace(%I::text, $1, $2)::jsonb WHERE strpos(%I::text, $1) > 0', c.tbl, c.col, c.col, c.col)
      USING old_base, new_base;
    GET DIAGNOSTICS n = ROW_COUNT;
    RAISE NOTICE '%.%: % row(s)', c.tbl, c.col, n;
  END LOOP;
END $$;

It changes the address in the columns UserTasks stores file links in (the same list its own storage migration uses), and prints how many rows it changed in each. Run it against the cloud database:

Bash
psql 'postgresql://postgres.your-project-ref:YOUR-DB-PASSWORD@aws-0-us-east-1.pooler.supabase.com:5432/postgres' -v ON_ERROR_STOP=1 -f fix-storage-urls.sql

4. Point the app at the cloud project#

In .env.local (from source) or .env (Docker Compose), replace the local Supabase values with the cloud ones:

.env.localINI
NEXT_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
  • Keep ENCRYPTION_KEY exactly as it is if you copied your data. Connector passwords and tokens are stored encrypted with it (in app_kms and the connector tables), and a new key can't read them. npm run setup:local never replaces it, for the same reason. It also signs queued workflow resumes when WORKFLOW_SIGNING_SECRET isn't set.
  • Keep CRON_SECRET, or choose a new one: either way, store it in the cloud project's Vault below.
  • The Supabase URL and keys are read when the app starts, so a restart is enough for them: stop npm run dev or npm start and start it again.

Turn on scheduled jobs. Schedules, reminders and the run queue run when pg_cron in the database calls the app. On your laptop, npm run setup:local stored the app's address as http://host.docker.internal:3000 in the local Vault, which the cloud can't reach, and the Vault wasn't copied. Once the app has its public address (step 5), store it and the cron secret in the cloud project:

Bash
DATABASE_URL='postgresql://postgres.your-project-ref:YOUR-DB-PASSWORD@aws-0-us-east-1.pooler.supabase.com:5432/postgres' CRON_SECRET='your-cron-secret' npm run scheduler -- install-pg-cron --base-url https://tasks.yourcompany.com

It (re)creates the pg_cron jobs and stores app_base_url and cron_secret in Vault, and is safe to run again. Use the same value as CRON_SECRET in the app's settings (or WORKFLOW_PROCESSOR_SECRET, if you set that). npm run scheduler -- status shows what's installed.

5. Put the app somewhere public#

Your laptop isn't a server: pick a place your team can reach, and give it the same settings as your .env.local (the cloud Supabase values, ENCRYPTION_KEY, CRON_SECRET). Set APP_URL and NEXT_PUBLIC_APP_URL to the public address, for example https://tasks.yourcompany.com.

WhereHow
Docker on a server (simplest to own)Copy the folder to a VM, put your settings in .env, and run docker compose up -d --build (the default profile runs only the app, against your Supabase project). See Docker Compose, then Give your install a friendly address for the domain and HTTPS
VercelImport the repository as a project and add every setting under Environment Variables. NEXT_PUBLIC_APP_URL and DEPLOYMENT_MODE are read when Vercel builds, so redeploy after changing them; the Supabase URL and keys are read at runtime. Keep pg_cron as the scheduler (vercel.json only adds three daily fallback jobs), and note that uploads through the app are capped at 4 MB there (Supabase Storage uploads go straight to storage, so it doesn't apply to them)
KubernetesThe Helm chart in deploy/helm/usertasks: see Kubernetes (Helm). appUrl sets the address

Whichever you choose, APP_URL must be the address people open: it's used for sign-in redirects, links in emails and cookies. See Give your install a friendly address.

6. Sign-in settings in Supabase#

With Supabase Auth, the cloud project's own settings decide where people are sent after signing in. Your local supabase/config.toml only applies to the local stack.

  1. Authentication → URL Configuration:
    • Site URL: https://tasks.yourcompany.com.
    • Redirect URLs: add https://tasks.yourcompany.com/auth/callback. UserTasks sends people back there after a password reset, an email confirmation or Google / Microsoft sign-in; Supabase refuses return addresses that aren't on this list.
  2. Email: Supabase Auth sends the password-reset and confirmation emails itself. Its built-in mailer is meant for trying things out and sends only a few emails an hour, so set up your own SMTP server in the project's Authentication email settings. UserTasks' own emails (invitations, notifications, reminders) go through its email provider instead, such as RESEND_API_KEY or SMTP: see Email.
  3. Google or Microsoft sign-in: turn the provider on in the cloud project (Authentication → Providers), and in Google Cloud or Microsoft Entra ID add the callback URL that page shows, https://your-project-ref.supabase.co/auth/v1/callback. For Sign in with Microsoft, set NEXT_PUBLIC_SSO_MICROSOFT=1 too. See SSO and directory sync.

7. Check it#

  1. Sign in at https://tasks.yourcompany.com/login with your organisation slug, email and password (or create the admin account at /setup on a fresh start).
  2. Run the platform self-test: Settings → General → Platform self-test → Install self-test, then run the Kitchen sink workflow. It should end with "Kitchen sink: N/N passed". See Platform self-test.
  3. Check scheduled jobs a few minutes after step 4's install-pg-cron. usertasks-admin doctor reports the pg_cron jobs and the last tick ("last tick … min ago"):
Bash
npm run admin -- doctor

Run it with the cloud settings in the environment (DATABASE_URL set to the connection string, plus the Supabase URL and keys), or with Docker: docker compose exec app node admin.cjs doctor.

  1. Open a few files: a logo, an attachment on a task or form.

8. Troubleshooting#

db push fails#

  • "Remote migration versions not found in local migrations directory": the project isn't empty, or something else wrote to it. Use a new, empty project.
  • It applied nothing, or changed your local database: the CLI ran against the local stack. Add --linked (as above).
  • Connection or password errors: run npx supabase link --project-ref your-project-ref again and re-enter the database password, or reset it in the dashboard.

"permission denied" or "duplicate key" when restoring#

  • "duplicate key value violates unique constraint": rows from the migrations are still there. Run the delete from … line in step 3 first. Restore into a database that has only had db push: if an earlier restore was partly committed, start again with a fresh project.
  • "permission denied": connect as the postgres user with the connection string from the Connect button, not with an API key, and dump only the schemas listed in step 3 (Supabase's own schemas, such as storage internals or vault, can't be written from outside).
  • "column … does not exist" in an auth table: the local Supabase is older than the cloud. Update the CLI (npx supabase@latest), run npx supabase stop and npx supabase start so the local auth service catches up, then dump again.

People can't sign in after the move#

  • "Invalid email or password" for everyone: the auth rows weren't restored. Check that the dump included auth.
  • Sent back to the login page, or to localhost: the Site URL and Redirect URLs (step 6), or APP_URL (step 5), still have the old address.
  • The organisation isn't found: the public rows weren't restored.

Files are missing#

  • A file opens a "not found" error: the bucket wasn't copied, or only partly. Run that bucket's two cp lines (step 3) again.
  • A link still says 127.0.0.1:54321 or localhost: run fix-storage-urls.sql (step 3), with old_base matching the address in the link. Links saved somewhere else (an email already sent, an outside system) can't be changed: upload the file again in the app.

Schedules don't run#

  • Run the install-pg-cron command from step 4 again, with the public address (never host.docker.internal or localhost).
  • The cron secret in Vault must equal CRON_SECRET (or WORKFLOW_PROCESSOR_SECRET) in the app's settings.
  • The app must be reachable from the internet at that address, over HTTPS with a valid certificate.
  • npm run admin -- doctor shows the last tick and any failing job.

Next#

Give your install a friendly address.

Was this page helpful?