# Move in from a managed database

> Move a database from any managed provider onto your own server, with near-zero downtime.

Source: https://rowsafe.sh/docs/guides/move-in

**Move in** copies a database from a managed provider (DigitalOcean, RDS, Aurora, Supabase, Neon, Heroku, Render, Railway, Crunchy Bridge, Cloud SQL, Azure, ...) onto your server while your apps keep running. Then you switch over in seconds. From then on it has continuous backups, [Rewind](https://rowsafe.sh/docs/guides/restore), [Proof](https://rowsafe.sh/docs/concepts/restore-drills) and [Pulse](https://rowsafe.sh/docs/guides/monitoring).

The data goes straight from the old database to your server, never through Rowsafe.

| Database                                | Live sync                 | One-time copy |
| --------------------------------------- | ------------------------- | ------------- |
| PostgreSQL                              | Yes                       | Yes           |
| [MySQL and MariaDB](#mysql-and-mariadb) | Yes                       | Yes           |
| [MongoDB](#mongodb)                     | Yes (replica sets)        | Yes           |
| [ClickHouse](#clickhouse)               | No                        | Yes           |
| [Redis and Valkey](#redis-and-valkey)   | Only from a Redis you run | Yes           |

This page describes PostgreSQL; the other sections say what differs.

## Before you start

- **A server with Rowsafe and PostgreSQL**, the same major version or newer (16 to 18 works). [Add it](https://rowsafe.sh/docs/quickstart) first.
- **Free disk:** the database's size plus a fifth. A one-time copy needs about twice that.
- **The same extensions.** The check lists any your server lacks.
- **Network:** your server must reach the old database. Most providers need your server's IP allowed: see [your provider](#provider-by-provider).
- **The old database's connection string**, with its admin user.

## Move it

### Pick the server

Open **Move in**, click **Move a database in**, and pick the database to move into.

### Paste the connection string

Paste it and click **Check the database**. The dashboard warns about common mistakes, like a pooler address.

Your browser encrypts it for your server's agent only; Rowsafe can't read it. See [how your password is handled](#how-your-password-is-handled).

### Read the check

The agent checks both sides without changing anything: versions, replication, the user's rights, extensions, free space and more. Each problem comes with your provider's steps.

**Tables without a primary key:** live sync can't follow their updates and deletes. Add a primary key, or click **Fix it for me** (Rowsafe sets `REPLICA IDENTITY FULL` on them at the source; your data doesn't change).

### Choose how to move

- **Live sync** (recommended): Rowsafe copies every table while your apps keep writing, then follows each change. Downtime is only the switchover: seconds.
- **One-time copy:** when live sync isn't possible (Heroku, for example). Writes stop while Rowsafe copies; the check estimates how long.

### Follow the copy

The page shows the tables copied and how far behind your server is. "Nothing" behind means ready to switch.

### Switch over

Pick a quiet moment, click **Switch over**, and choose how writes stop:

- **Make the old database read-only for me:** Rowsafe makes it read-only and disconnects its sessions. If it can't, it undoes that and asks you to stop writes yourself.
- **I stopped my apps' writes myself:** Rowsafe doesn't touch the old database's settings.

Rowsafe waits for the last change, sets sequences, ends the sync, compares row counts, and creates a login for your apps. Its connection string is shown **once**, in your browser.

### Point your apps at the new database

Put the new connection string in your apps (for example `DATABASE_URL`) and restart them. Lost it? **Get a new password**.

The old database stays as it was, for rollback: **Make it writable again** and point your apps back. When you're sure, click **I'm done with it**, then delete the old database at your provider.

**With the CLI**

`rowsafe migrate start`, `rowsafe migrate switch` and `rowsafe migrate finish` ([CLI reference](https://rowsafe.sh/docs/reference/cli#move-in)):

```sh
export OLD_DB='postgres://doadmin:...@db-postgresql-fra1-123.b.db.ondigitalocean.com:25060/shop?sslmode=require'
rowsafe migrate start app --source-env OLD_DB   # check, start, wait until caught up
rowsafe migrate switch mig_5k2m9x7q4t1v         # prints the new connection string once
```

## Let your apps connect

Apps on the same server connect as they are. Apps on other servers need PostgreSQL to listen on the network and let them in; the check warns when it doesn't. Keep your firewall closed to everyone else.

**Do it yourself**

On Debian and Ubuntu, in `/etc/postgresql/18/main/postgresql.conf`:

```ini
listen_addresses = '*'
```

In `pg_hba.conf`, one line per app server (or private network), then restart PostgreSQL:

```ini
hostssl  shop  app  10.0.0.0/24  scram-sha-256
```

## Provider by provider

What each provider needs for live sync, from its own docs. The check tells you which applies.

### DigitalOcean

- Use the `doadmin` user and `sslmode=require` ([DigitalOcean's guide](https://docs.digitalocean.com/products/databases/postgresql/how-to/migrate-to-self-managed/)). Managed PostgreSQL has no full superuser, so some role operations may need attention.
- Add your server's IP under **Network Access > Trusted sources** (IPv4 only) ([secure a cluster](https://docs.digitalocean.com/products/databases/postgresql/how-to/secure/)).

### Amazon RDS for PostgreSQL

- Set `rds.logical_replication` to `1` in a **custom** DB parameter group and **reboot**. Use the master user, or grant `rds_replication` ([AWS docs](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.FeatureSupport.LogicalReplication.html)).
- Allow your server's IP on port 5432 in the security group.

### Amazon Aurora PostgreSQL

- Set `rds.logical_replication` to `1` in a **custom DB cluster parameter group** and reboot the writer. Needs `rds_superuser` ([AWS docs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Replication.Logical.Configure.html)).
- Use the writer (cluster) endpoint.

### Supabase

- Use the **direct connection** (`db.<project>.supabase.co`), not the pooler, and the `postgres` user. It's IPv6 unless you turn on Supabase's IPv4 add-on ([Supabase docs](https://supabase.com/docs/guides/database/postgres/setup-replication-external), [connecting](https://supabase.com/docs/guides/database/connecting-to-postgres)).
- Supabase's own schemas and services (Auth, Storage) don't move. Statements that need them are skipped and listed.

### Neon

- **Settings > Logical replication > Enable.** This restarts your computes and can't be undone ([Neon docs](https://neon.com/docs/guides/logical-replication-postgres)).
- Use the connection string **without** `-pooler`, and a role created in the Console, CLI or API (not with SQL). With IP Allow on, add your server's IP. Neon removes inactive replication slots after about 40 hours ([logical replication in Neon](https://neon.com/docs/guides/logical-replication-neon)).

### Heroku Postgres

- No live sync ([Heroku docs](https://devcenter.heroku.com/articles/heroku-postgres-import-export)). Rowsafe uses the **one-time copy**.

### Render

- Logical replication needs a support request (Pro workspaces and up). The user must own the tables; otherwise use the one-time copy ([Render docs](https://render.com/docs/postgresql-logical-replication)).

### Railway

- Run `ALTER SYSTEM SET wal_level = 'logical';` and restart the service. Use `DATABASE_PUBLIC_URL` ([Railway docs](https://docs.railway.com/guides/migrate-database-minimal-downtime)).

### Crunchy Bridge

- Ready by default. Allow your server's IP in the cluster's firewall ([Crunchy docs](https://docs.crunchybridge.com/how-to/logical-replication)).

### Google Cloud SQL

- Set the flag `cloudsql.logical_decoding` to `on` (restarts the instance). The user needs `cloudsqlsuperuser` and `ALTER USER your_user WITH REPLICATION;`. Add your server's IP to authorized networks ([Google docs](https://docs.cloud.google.com/sql/docs/postgres/replication/configure-logical-replication)).

### Azure Database for PostgreSQL

- Set `wal_level` to `logical` and restart (Azure suggests `max_worker_processes` of at least 16). Run `ALTER ROLE your_admin WITH REPLICATION;`. Allow your server in networking ([Azure docs](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-logical)).

### Any other PostgreSQL

- `wal_level = logical` and a restart; a superuser, or a `REPLICATION` user that owns the tables; your server's IP allowed in `pg_hba.conf` and the firewall ([PostgreSQL docs](https://www.postgresql.org/docs/current/logical-replication-config.html)).

## MySQL and MariaDB

From RDS, Aurora MySQL, Cloud SQL, Azure, DigitalOcean or any MySQL, into the same flavor (MySQL into MySQL, MariaDB into MariaDB), same version or newer. What differs:

- **Connection string:** `mysql://user:password@host:3306/database` (add `?ssl-mode=REQUIRED`, or `DISABLED` without TLS). One database per move.
- **Your server:** install Rowsafe there with standby servers allowed (`--mysql-standby`).
- **Live sync** needs the source's binary log in `ROW` format (on RDS: automated backups on, `binlog_format = ROW`) and a user with `REPLICATION SLAVE` and `REPLICATION CLIENT`. On RDS, the check offers **Keep them 24 hours** for the binary logs (one click).
- **Stop your app's writes yourself** before the switchover: providers don't let Rowsafe make MySQL read-only.
- **Moves:** tables, views, routines, triggers and events. Logins don't; the new login gets every right on the moved database.

## MongoDB

From MongoDB Atlas, DigitalOcean or any MongoDB:

- **Connection string:** Atlas's `mongodb+srv://user:password@cluster.example.net/database`, or `mongodb://user:password@host:27017/database?authSource=admin`.
- **Live sync** when the source is a replica set (Atlas always is). The user needs read on the database (on Atlas, `readAnyDatabase`). Stop your app's writes at the switchover.
- **Your server:** install Rowsafe there with `--mongodb-clones`.
- **Moves:** documents and indexes (not indexes created during the sync). Users and roles don't; the new login gets `readWrite` and `dbAdmin` on the moved database.

## ClickHouse

From ClickHouse Cloud, Altinity, Aiven or any ClickHouse, as a **one-time copy**:

- **Connection string:** `https://user:password@host:8443/database` (ClickHouse Cloud: Connect > HTTPS).
- **Stop your app's writes** during the copy; the check estimates how long.
- **Your server:** install Rowsafe there with `--clickhouse-clones`.
- **Moves:** tables and views. ClickHouse Cloud's `Shared*` engines become `MergeTree`. Tables that read other systems (Kafka, S3, ...) are created but not copied. Users and grants don't move.

## Redis and Valkey

From ElastiCache, MemoryDB, Upstash, Redis Cloud, Azure Cache for Redis, DigitalOcean, Aiven or any Redis, into an **empty** Redis or Valkey server. Paste `rediss://default:password@host:6379` (`redis://` without TLS; add `?skip_verify=true` only if the provider's certificate isn't trusted on your server).

- **One-time copy** (every managed provider): keys and their time to live. Stop your apps' writes for the copy.
- **Live sync** only from a Redis that lets replicas connect (usually one you run).
- The check covers versions, modules, `maxmemory` and eviction. ElastiCache and MemoryDB are reachable only from inside their VPC. Redis Cluster isn't supported.
- A login for apps needs `--redis-standby` at install.

## How your password is handled

- Your browser (or the CLI) seals the connection string for a key the agent made for this move (ECDH P-256, HKDF-SHA256, AES-256-GCM). Rowsafe relays only ciphertext and deletes it once delivered.
- On your server, it's in a file only the agent and PostgreSQL can read (`/var/lib/rowsafe/migrate/<id>/`, mode 0600). Never on a command line, in a log, or in your backups. **I'm done with it** and **Cancel** delete it.
- The new login's password is made on your server. Its connection string is sealed to your browser, kept at most 30 minutes, and shown once.

## What doesn't move, and other limits

- **Roles and privileges:** one new login owns everything. Recreate other users if you need them.
- **Don't change table structure during live sync:** schema changes aren't copied.
- **Large objects and unlogged tables** need the one-time copy.
- **Tables the user doesn't own** can't be live-synced. Connect as their owner, or use the one-time copy.
- **Provider-only extensions** (`aws_s3`, `pgsodium`, `neon`, ...) are left out; what depends on them is listed.
- **The sync uses disk at the source.** If your server stops following for long, the old database's log piles up. Cancelling cleans it up.
- **Docker sidecar agents** need `pg_dump` and `pg_restore` of the server's version; the check says when they're missing.
- AI agents on [MCP](https://rowsafe.sh/docs/reference/mcp) can't start or change a move in.
