Skip to content
Least-privilege method for a verified Production PostgreSQL backup
chloeos-platform
OP

25 days ago

Hello Railway Support,

I need the officially supported, least-privilege method to create a verified backup of a Production PostgreSQL service without modifying Production.

We tested railway ssh using a temporary Project Token restricted to the relevant project and environment, together with a temporary account SSH key. The Railway identity check succeeded, but the SSH connection did not complete and was cancelled after 45 seconds. No backup was created, no Production data was modified, and both temporary credentials have been revoked.

Please confirm the lowest-scope supported method for a read-only PostgreSQL export suitable for an encrypted backup and an isolated local restore verification. We do not want to use OAuth, broader account tokens, deploy changes, migrations, service changes, replicas, volumes, or plan changes.

If railway ssh requires a different credential or permission model, please specify the minimum exact scope and whether it can be restricted to one project, the Production environment, and the PostgreSQL service. If a safer native backup or export method exists, please provide the documented procedure.

Please do not request secrets in this public thread. If sanitized, non-secret diagnostics are required, please tell us the appropriate authorized private channel.

Solved

5 Replies

Railway
BOT

25 days ago

Project tokens only cover deployment-related actions such as railway up, railway redeploy and railway logs, and they don't work for SSH key management. That fits your attempt not completing with that token. SSH access needs either railway login or a workspace API token, plus an SSH key registered to your account or to the workspace. Workspace keys give SSH access to every service in the workspace. The SSH options don't offer a key or credential limited to one project, environment or service.

With that access in place, nothing in Production has to change. You can run a single non-interactive command in the Postgres service with railway ssh -p <project> -e production -s <postgres-service> -- <command>. When the input is piped, no PTY is allocated, so the output stays clean for scripts. You can also forward a local port into the container with ssh -N -L, which reaches only the container's loopback and your project's private network, and then run your export tool locally through that tunnel. For copying files out, scp and sftp work against ssh.railway.com with the same registered key. See railway ssh.

Native volume backups can only be restored into the same project and environment they came from. A restore also stages a volume swap on the service, so they don't fit an isolated local restore check. For a verified offline copy, use a logical export over SSH as described above.


Status changed to Awaiting User Response Railway • 25 days ago


chloeos-platform
OP

25 days ago

Hello Railway Support,

Thank you for the automated response.

We understand that SSH may require broader access than a Project Token. However, we do not want to expand permissions based only on the bot response.

Could a Railway support engineer please confirm the least-privilege supported method for creating a verified PostgreSQL backup from Production?

Our requirements are:

  • read-only access where possible;
  • no Production changes;
  • no public proxy unless strictly required;
  • no broader workspace/account permissions unless unavoidable;
  • ability to stream pg_dump, encrypt locally, and restore into an isolated PostgreSQL instance for verification.

Please confirm whether:

  1. railway ssh can be used safely with a pre-registered SSH key and a narrowly scoped credential;
  2. there is a supported alternative that avoids broad OAuth/account access;
  3. Railway provides a native backup/snapshot/export path that can be independently restored and verified;
  4. what exact permissions are required for the recommended method.

We will not recreate temporary credentials or retry SSH until a human support engineer confirms the supported approach.

Thank you.


Status changed to Awaiting Railway Response Railway • 25 days ago


Railway
BOT

25 days ago

Project tokens (RAILWAY_TOKEN) cover project-level actions like deploys, variables and logs. They can't be used to manage SSH keys, so they aren't a working credential for SSH on their own. SSH needs either railway login or a workspace-scoped RAILWAY_API_TOKEN, plus an SSH key registered to your personal account or to the workspace. Workspace-owned keys give SSH access to every service in the workspace, and adding them requires workspace Admin. There is currently no SSH key or token that can be limited to one project, environment or service.

Once that access is in place, nothing in Production has to change. railway ssh -p <project> -e production -s <postgres-service> -- <command> runs a single command, and piped commands run without a PTY, so you can stream pg_dump output straight into local encryption. You can also use ssh -N -L to forward a local port to the container's loopback. Forwarding only reaches the container and your project's private network, so you don't need a public TCP proxy. See railway ssh. Making the export read-only at the database level, for example with a dedicated read-only Postgres role for pg_dump, is set up inside Postgres itself.

Native volume backups can only be restored into the same project and environment they came from, and a restore stages a volume swap on the service. That means they can't be restored independently into an isolated local instance. For an encrypted copy you verify offline, a logical pg_dump export over SSH is the path.


Status changed to Awaiting User Response Railway • 25 days ago


Railway

Project tokens (`RAILWAY_TOKEN`) cover project-level actions like deploys, variables and logs. They can't be used to manage SSH keys, so they aren't a working credential for SSH on their own. SSH needs either `railway login` or a workspace-scoped `RAILWAY_API_TOKEN`, plus an SSH key registered to your personal account or to the workspace. Workspace-owned keys give SSH access to every service in the workspace, and adding them requires workspace Admin. There is currently no SSH key or token that can be limited to one project, environment or service. Once that access is in place, nothing in Production has to change. `railway ssh -p <project> -e production -s <postgres-service> -- <command>` runs a single command, and piped commands run without a PTY, so you can stream `pg_dump` output straight into local encryption. You can also use `ssh -N -L` to forward a local port to the container's loopback. Forwarding only reaches the container and your project's private network, so you don't need a public TCP proxy. See [railway ssh](https://docs.railway.com/cli/ssh). Making the export read-only at the database level, for example with a dedicated read-only Postgres role for `pg_dump`, is set up inside Postgres itself. Native volume backups can only be restored into the same project and environment they came from, and a restore stages a volume swap on the service. That means they can't be restored independently into an isolated local instance. For an encrypted copy you verify offline, a logical `pg_dump` export over SSH is the path.

chloeos-platform
OP

25 days ago

Hello Railway Support,

The responses received so far appear to be automated. We understand that Railway SSH may require broader access, but we have not authorized expanding permissions yet.

Could a human Railway support engineer please confirm the officially supported, least-privilege method for obtaining a verifiable PostgreSQL Production backup?

Our sole objective is to stream a pg_dump, encrypt it locally, and verify it by restoring it into an isolated PostgreSQL instance—without modifying Production.

We will not create broader credentials or retry SSH until we receive human confirmation.

Thank you.


Status changed to Awaiting Railway Response Railway • 25 days ago


Railway
BOT

25 days ago

On your four questions:

  1. railway ssh cannot be scoped to one project, environment or service. It needs either railway login or a workspace-scoped RAILWAY_API_TOKEN, plus an SSH key registered to your personal account or to the workspace. Project tokens (RAILWAY_TOKEN) cannot be used to manage SSH keys. Workspace-owned keys give SSH access to every service in the workspace, and adding them requires workspace Admin. The smallest footprint is a personal SSH key used with railway login, revoked when you are done.

  2. The only route that avoids Railway account credentials entirely is connecting with a Postgres connection string through Public Access on the database. That creates a TCP proxy, which is a change to the service and a public endpoint, so it does not meet your requirements. SSH does not need any change to Production. You can stream a single piped command such as pg_dump (no PTY is allocated), or hold an ssh -N -L tunnel that only reaches the container's loopback and your project's private network.

  3. Native volume backups can only be restored into the same project and environment, and a restore stages a volume swap on the service. You cannot independently restore one into an isolated local instance. For an offline, encrypted, verified copy, the path is a logical pg_dump over SSH.

  4. Read-only access at the database level is set inside Postgres, for example a dedicated read-only role used for pg_dump.

See railway ssh and Backups.


Status changed to Awaiting User Response Railway • 25 days ago


Railway
BOT

17 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway • 17 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...