Move a database from Railway
Copy a database from Railway into an openrail database service with one pipe through openrail connect.
Before you start
- In Railway, turn on the database's public network access and copy its public URL (
DATABASE_PUBLIC_URLand the like). - In openrail, create the same database type (or import the project) and link your directory:
openrail link -s Postgres. - Install the client tools locally (
pg_dumpandpsql,mysqldumpandmysql,redis-cli,mongodumpandmongorestore). - Stop writes to the Railway database, or plan a short final sync.
Postgres
pg_dump "$RAILWAY_URL" --no-owner --no-acl | openrail connect Postgres -- psqlMySQL
mysqldump --single-transaction --routines "$RAILWAY_DB" -h "$HOST" -P "$PORT" -u "$USER" -p"$PASSWORD" | openrail connect MySQL -- mysqlRedis
redis-cli -u "$RAILWAY_REDIS_URL" --rdb dump.rdbThen load dump.rdb into the new service's volume: openrail connect Redis --tunnel-only gives you a local URL for tools that replay keys, or copy the file in with openrail ssh and restart.
MongoDB
mongodump --uri "$RAILWAY_MONGO_URL" --archive --gzip | openrail connect MongoDB -- mongorestore --archive --gzipCheck and switch
- Compare row or key counts.
- Point services at the new database with
${{Postgres.DATABASE_URL}}(imports already do). - Deploy, then turn off public access on the Railway database.