|
| 1 | +--- |
| 2 | +title: Live migration |
| 3 | +excerpt: Migrate an entire database with low downtime |
| 4 | +products: [cloud] |
| 5 | +keywords: [migration, low-downtime, backup] |
| 6 | +tags: [recovery, logical backup, replication] |
| 7 | +--- |
| 8 | + |
| 9 | +# Live migration |
| 10 | + |
| 11 | +Live migration is a migration strategy to move a large amount of data |
| 12 | +(100 GB-10 TB+) with low downtime (on the order of minutes of |
| 13 | +downtime). It is significantly more complicated to execute than a migration |
| 14 | +with downtime using [pg_dump/restore][pg-dump-and-restore], but supports more |
| 15 | +use-cases and has less requirements than the [dual-write and backfill] method. |
| 16 | + |
| 17 | +<SourceTargetNote /> |
| 18 | + |
| 19 | +Live migration leverages Postgres' built-in replication functionality to |
| 20 | +provide a seamless migration with very little application downtime. |
| 21 | + |
| 22 | +Roughly, it consists of four steps: |
| 23 | + |
| 24 | +1. Prepare and create replication slot in source database. |
| 25 | +2. Copy schema from source to target, optionally enabling hypertables. |
| 26 | +3. Copy data from source to target while capturing changes. |
| 27 | +4. Apply captured changes from source to target. |
| 28 | + |
| 29 | +Currently live migration only supports migrating from PostgreSQL, but we are |
| 30 | +actively working on supporting TimescaleDB. |
| 31 | + |
| 32 | +Live migration works well when: |
| 33 | +- Large, busy tables have primary keys, or don't have many `UPDATE` or |
| 34 | + `DELETE` statements. |
| 35 | +- The insert workload does not exceed 20'000 rows per second, and |
| 36 | + inserts are batched. If your application exceeds this, you should use |
| 37 | + the [dual-write and backfill] migration method. |
| 38 | + |
| 39 | +For more information, consult the step-by-step migration guide: |
| 40 | + |
| 41 | +- [Live migration from PostgreSQL][from-postgres] |
| 42 | + |
| 43 | +[from-postgres]: /migrate/:currentVersion:/live-migration/live-migration-from-postgres/ |
| 44 | +[pg-dump-and-restore]: /migrate/:currentVersion:/pg-dump-and-restore/ |
| 45 | +[dual-write and backfill]: /migrate/:currentVersion:/dual-write-and-backfill/ |
0 commit comments