惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
T
Tenable Blog
V
Vulnerabilities – Threatpost
T
Troy Hunt's Blog
SecWiki News
SecWiki News
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Secure Thoughts
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
H
Heimdal Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
N
News and Events Feed by Topic
The Hacker News
The Hacker News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
Forbes - Security
Forbes - Security
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
T
Tor Project blog
WordPress大学
WordPress大学
AWS News Blog
AWS News Blog
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
Cloudbric
Cloudbric
O
OpenAI News
U
Unit 42
Google DeepMind News
Google DeepMind News
Simon Willison's Weblog
Simon Willison's Weblog
Recorded Future
Recorded Future
N
News | PayPal Newsroom
S
Schneier on Security
F
Full Disclosure
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
P
Privacy International News Feed
L
LINUX DO - 最新话题
F
Fortinet All Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements

Railway Blog

Where Railway is, and where it's going (Summer 2026) PaaS vs IaaS vs SaaS: What Each Means and Who Should Pick What in 2026 The Best Continuous Deployment Tools in 2026 The Best PaaS for Multi-Region Deployments in 2026 The Best Platforms for Monorepo Deployments in 2026 Compliance Isn't a Feature, It's a Posture What is BYOC (Bring Your Own Cloud)? A Developer's Guide for 2026 The Best Managed Kubernetes Hosting in 2026 The Best Container Registries in 2026 The Vanilla Cloud Tax: What Rolling Your Own on AWS Actually Costs What is a PaaS? A Developer's Guide for 2026 The Best Cloud Observability and Logging Tools in 2026 The Best PostgreSQL Hosting for Developers in 2026 The Best Multi-Region Hosting Platforms in 2026 The Best Platforms to Deploy AI Apps in 2026 (Not the Models, the Apps Around Them) The Agent-Native Cloud: What It Means and Why It Matters Incident Report: May 19, 2026- GCP Account Suspension Counting to 3 with a new builder processing 50M+ monthly builds Railway iOS preview now available via TestFlight Kill your onboarding: selling to 10,000+ new users a day Your AI wants to nuke your database. Guardrails fix that. Better Rails for Agents: A New Remote MCP and Railway Agent in the CLI Moving Railway's Frontend Off Next.js One command deploys, there's a Stripe APP for that From registrar to deployed: buying a domain inside Railway A letter to open source builders who deserve more Networking is a black box, we used eBPF to open it Heroku Walked So Railway Can Run Security Features Your Security Team Will Love Railway Runs Open Source, Now We're Funding It Railway raises $100M Series B to unburden the builders Deploy autoscaling services, AI Workflow automation, and LLM APIs Without Kubernetes Hosting Postgres with GeoLite2: a practical guide to IP geolocation, data loading, and updates Serverless functions vs containers: CI/CD, database connections, cron jobs, and long-running tasks Hosting Postgres with pgvector: provider tradeoffs, migrations, indexes, and tuning Introducing the Railway integration on Delve.co Secure Cloud Hosting for Compliance: A Practical Guide for Startups and Regulated Industries How G2X Unlocked Rapid Experimentation at Scale with Railway MindFort Runs 100+ AI Pen Testing Agents Without Their Previous $10k AWS Bill How Bilt's Marketing Engineering Team Delivers at Scale with Railway Railway Technology Partners: Earn Revenue on Templates You Didn't Build ~$1 Million Paid to Developers Who Built Railway Templates CI/CD for Modern Deployment: From Manual Deploys to PR Environments Kernel Powers 1,000+ AI Agents on $444/Month of Railway Infrastructure Deploy Full-Stack TypeScript Apps: Architectures, Execution Models, and Deployment Choices Railway vs Cloudflare: How Their Architectures Differ and When to Use Each Run Scheduled and Recurring Tasks with Cron Monitoring & Observability: Using Logs, Metrics, Traces, and Alerts to Understand System Failures Logs, Metrics, and Traces: What Does Each Signal Tell You? Server rendering benchmarks: Railway vs Cloudflare vs Vercel Top five Heroku alternatives Comparing top PaaS and deployment providers Pricing to Encourage Use The F in SOC2 stands for functional Deploy Together, Earn Together: Introducing Railway Partnerships How We Oops-Proofed Infrastructure Deletion on Railway Bring Back the Free Plan Railway MCP - Stateful, Serverful, Pay-per-use Infrastructure Hackathon: Winners Announced! Mark Your Calendar: Railway User Hackathon with Prizes Launching Railway's Affiliate Program Zero-Touch Bare Metal at Scale Ssh, We’re Announcing One More Thing! $1M for Open Source Introducing Central Station Speed Isn’t Just About Code, It’s About Where That Code Runs One-Second Deploys? We Didn’t Believe It Either Why We’re Moving on From Nix Railway V3: Faster and Cheaper How to Migrate from Cloudflare Pages to Railway Supercharging Directus on Railway with a Static Frontend How to Migrate from AWS Lambda to Railway Deploy Triton Inference Server on Railway How to Handle Database Connection Pooling Building a NestJS App on Railway Manually Optimize Deployments on Railway Implement a GitHub Actions Testing Suite Scaling a SaaS application on Railway Building a SaaS application on Railway Deploy a Dart App on Railway, Part 2 Deploy a Dart App on Railway, Part 1 Implementing Feature Flags from Scratch Cron Jobs with Django and GitHub Actions Deploy Offen on Railway Queues on Railway Working with NX, Railway and CI/CD Automated PostgreSQL Backups Using GitLab CI/CD with Railway Migrating From Heroku To Railway Cron Jobs on Railway Deploy Beam on Railway Deploy Authorizer on Railway Deploying Monorepo Applications How to Backup Your Redis Instance Deploy Cusdis on Railway Deploy Ghost on Railway Using Github Actions with Railway Deploy Calendso (cal.com) on Railway Self-hosted website analytics Use Notion as a CMS for your NextJS blog
How to Backup and Restore Your Postgres Database
Angelo Saraceno · 2021-08-31 · via Railway Blog

PostgreSQL, also known as Postgres, is a free and open-source relational database. It's a popular choice for applications big and small: and you can deploy it for free as a plugin on Railway.

Getting Started

If you haven't already, you will need to have psql installed. psql is going to be the command line interface that we will be using to interface with our Railway Postgres database. This includes pg_dump and pg_restore the two commands we will be using.

How to Install PSQL CLI

MacOS: Those on MacOS can use Homebrew to install Postgres, this includes the psql client.

brew update
brew install postgresql

Ubuntu: You can install the Postgres client separately without having to install the full server.

sudo apt-get update
sudo apt-get install postgresql-client

Windows: We recommend using WSL2 or you can install the Postgres tools with the Windows installer.

We also assume you have a Postgres instance on Railway with tables populated with data.

Backing Up Your Database

We will be using a tool that comes with the psql tools called pg_dump. The command pg_dump writes a file locally a copy of your database.

pg_dump -U <username> -h <host> -p <port> -W -F t <db_name> > <output_filename>

Heroku Specific Instructions

Keep in mind, Heroku’s Postgres Image uses a specialized dump format. We have heard reports of users needing to use the following command to get a platform agnostic dump. Note: Heroku heroku pg:backups:download will not work.

pg_dump -h <host> -d <database> -U <user> -p <port> -W -F t > latest.dump

We have a Heroku specific restoration command in the next section.

Getting Your Postgres Credentials

In order to execute the command. We will need the following information retrievable from the Project Variables page of your Railway project.

Under the Project Variables, after you expand the PostgreSQL variables dropdown you should take note of the following information.

Connection Information (1).png
  1. The username: PGUSER
  2. The host name: PGHOST
  3. The port to the database instance: PGPORT
  4. The name of the database: PGDATABASE
  5. The password to the database: PGPASSWORD

We can now structure the command to use these parameters in the following way.

pg_dump -U PGUSER -h PGHOST -p PGPORT -W -F t PGDATABASE > YOUR_FILENAME_HERE

Your command should look like the following.

pg_dump -U postgres -h containers-us-west-15.railway.app -p 5802 -W -F t railway > mydatabasebackup

💡 Keep in mind to run the command in the directory where you want the backup to be stored!

After everything looks good! You are good to execute the command. After when you press enter, you will be prompted to enter your PGPASSWORD to authenticate into the DB to perform the command.

Command Result

The command takes some time to run, keep in mind, the more data in the database, the longer it will take to complete.

We can see after the command completes, if we were to run ls or the Windows equivalent we can see the backup in the directory where we ran the command in.

Terminal Result.png

Restoring Your Database Backup

As mentioned in Getting Started, we can use pg_restore to restore the backup we made of our database.

Head over to your other project with a PostgreSQL plugin instantiated. I have a sample project with no data that we will be restoring our data to.

Empty PG Plugin.png

We will need the same parameters that we got last time from the Project Variables section as shown before.

The PG Restore Command

pg_restore connects to a PostgreSQL database and restores a backup made from pg_dump. The command is structured in the following way:

pg_restore -U <username> -h <host> -p <port> -W -F t -d <db_name> <dump_file_name>

After you gather your variables for the database instance you want to restore to, your command should look like the following:

pg_restore -U postgres -h containers-us-west-15.railway.app -p 6473 -W -F t -d railway mydatabasebackup

⚠️ If you are using Prisma ORM, your command might finish with a warning. Don't fret, your data would import as normal.

Heroku Specific Instructions

Reference the dump file that you got from before and run the following commands with the Railway DB connection variables.

pg_restore -U <USER> -h <HOST> -p <PORT> -W -F t -d <DATABASE> latest.dump

After the command completes: your tables and data should be restored as normal. You can see the results of DB under the data tab in your plugin.

Export Result.png

Closing

And with that you should have all the information you need to backup and restore your PostgreSQL database plugin on Railway.

If you have any suggestions for more guides, let us know on Discord!