Move an application to another cluster
If you redeploy somewhere else, copy the data by hand and change the address, every step can lose writes or traffic, and none of it can be undone once you are halfway.
In Flui, a move is one operation. Flui builds the new copy beside the old one, keeps it in step, and swaps the two only when you say so, or as soon as the copy is ready if you asked for that. Until the swap, nothing on the source has changed and you can cancel the whole move.
Three kinds of move
There are three commands because each kind of move carries different risks.
| You want to move | Command | What crosses |
|---|---|---|
| An application | flui migrate app | The running copy, its volumes, and its address |
| A Flui-managed PostgreSQL database | flui migrate db | The data |
| An application and the database it reads | flui migrate full | Both, in one cutover |
migrate app moves the application and the files it
keeps. The application keeps its name and address, and
its volumes are copied to the new cluster. At cutover its
address is repointed there, and the old cluster keeps
forwarding to the new one for a while, so nobody lands on
an empty cluster (see
What your users see during the cutover).
A database it reads is not included: use migrate db for
that, or migrate full for both.
migrate db moves only the data. When both clusters
are on the Flui network,
a live move copies the database privately over that
network. The copy is exact and kept in step continuously,
and nothing is opened to the internet. The new database
keeps the same database name, user and password as the
source; only its address changes.
In the other cases (the Flui network is off, or you rebuild from backups) the destination comes up with its own new address, name, user and password.
At cutover the source stops taking writes. After a
private copy it stops accepting connections altogether;
otherwise it is left read-only. Either way it stays like
that and is not removed. migrate db does not change what
your application connects to. migrate full does that for
you.
The shape of every move
Every move has four steps, and only the last two are permanent.
- Create. The destination is built and kept in step with the source. The source keeps serving.
- Cut over. Traffic, writes, or both move to the
destination.
--cutover autodoes this as soon as the destination is ready.--cutover manualpauses and waits for you. - Abort. Available until the cutover passes its point of no return. The destination is removed and the source is left as it was.
- Destroy the source. Optional, and only after the cutover. It gives the old cluster its capacity back, and cannot be undone.
Steps 2 and 4 are separate so you can check the result first. After the cutover the old copy stays in place until you destroy it. It still uses capacity, and while the old cluster is forwarding to the new one it is still doing a job.
A restart of Flui in the middle of an application move, a full move or a private database move does not lose it. The move picks up where it was.
What can move, and what cannot
Flui refuses a move it cannot finish when you ask for it, not halfway through. The refusal says which rule you hit. A full move checks the application’s rules too, before it copies the database.
An application can move when:
- it runs somewhere other than the target cluster;
- it does not read values out of another application’s secrets (move the applications it depends on first);
- it answers at a real domain. An application still on the fallback address built from its cluster’s IP cannot move, because that address belongs to the old cluster. Assign a DNS zone first: see Put an application on the internet;
- the target cluster has that DNS zone assigned too, so the name can follow the application;
- no other application that is staying behind answers at the same address. Give one of them its own name first;
- if it has volumes, there is a backup destination for
them to travel through: the one protecting the
application, your only one, or the one you name with
--backup-destination. See Protect and restore.
Only one migration can run at a time for each application.
migrate full has one more rule. Flui has to see, in the
application’s own configuration, that it points at the
database you named: either the standard PGHOST setting
matching the source database, or a postgres:// URL that
matches it. An application that reads its connection from
a linked secret cannot be rewired, so the move is refused
instead of guessed at. The exception is a database with a
connection pooler: an application that reads
FLUI_CONNECTION_URL or FLUI_DIRECT_URL from the database
itself is accepted, here and under the rule about other
applications’ secrets above, and Flui rewires it. In that case the
application must also be the only one using the database.
Move or repoint the others first; the refusal names them.
A private database move also needs the target cluster to be live on the Flui network. Flui checks this before it starts and refuses otherwise, telling you which node is missing. The network reconciles every 10 minutes, so you can wait for it and start the move again.
Start the move
# an application, with its volumesflui migrate app create my-api --to production-eu
# a managed databaseflui migrate db create orders-db --to production-eu
# both togetherflui migrate full create my-api --db orders-db --to production-eu--to (-t) is required and takes a cluster name or id.
You can give the application and the database by name or
by id. --from (-f) is optional: Flui looks for the name
on every cluster, workload clusters included, and asks you
for --from only when the same name is on more than one.
--cutover auto is the default on all three. Pass
--cutover manual to pause the move and start the cutover
yourself.
flui migrate app and flui migrate full take
--backup-destination to choose where volumes travel
through. flui migrate app also takes --no-bridge, which
moves only the DNS record at cutover and leaves the old
cluster out of it.
flui migrate db has four more flags:
| Flag | What it does |
|---|---|
--mode live|restore | live copies from the running database, then cuts over. restore rebuilds from its backups instead, for when the source is already gone. Default live. |
--at <ISO-8601> | Restore mode only: the point in time to recover to. |
--name | A display name for the new database. Defaults to the old one’s slug with -migrated on the end. |
--no-verify | Skips the per-table row-count comparison Flui makes at cutover. The check is on by default, and a mismatch stops the cutover. A private copy is exact, so it has no row count to compare. |
flui migrate full has --staging, which decides how the
new copy of the application waits:
scaled-down(the default): the copy is built but not started until cutover. This is safe, and the write pause at cutover is a little longer.live-fenced: the copy is started at full size against the destination database while that database is still read-only, so it is already warm at the swap. This shortens the pause, but your application has to meet two conditions. It must start and pass its health check without writing anything, and it must not run background work with effects outside the database (queue consumers, scheduled jobs, outgoing mail or webhooks) until cutover. Flui holds back only its database writes.
When the database has a connection pooler, flui migrate full
also takes --pause-deadline <seconds>. See
When the database has a pooler.
Go to Management → Migrations. New migration opens one form for all three kinds.
Pick the type first (App, Database or Full app), then the source and target clusters. The application and database pickers fill from the source cluster once it is chosen, so pick the source first. The form refuses a target that is the same as the source.
The rest of the form depends on the type. Cutover
(automatic or manual) is always there. An application move
asks which backup destination its volumes move through
when you have more than one. A database move adds the
mode, and once the mode is Restore, the new database’s
name and the recovery time. A full move adds the staging
choice, with the warning about what live-fenced requires
of your application next to it.
The row-count check stays on, and an application move always uses the bridge. To change either, use the CLI or an agent.
There is one tool per kind:
migrate_app: takessrcAppId,targetClusterId, and optionalcutover,backupDestinationIdandbridge(falsemoves DNS only).migrate_db: takessrcAppId,targetClusterId, and optionalcutover,mode,displayName,recoveryTargetTimeandverifyRowCounts.migrate_full: takesappId,dbAppId,targetClusterId, and optionalcutover,stagingandpauseDeadlineSeconds.
Application ids come from app_list (a managed database
is an application of kind DATABASE), and cluster ids from
cluster_list.
All three are in the Run migrations permission group.
The work is not finished when the call returns. Each call returns a migration id and an operation id. Nothing polls for the agent, and an agent should not report a move as done based on the create call.
Starting a database move or a full move stops and asks you. Both are part of the action cycle: when the caller is an agent, the call does not run. It returns a request id and a sentence you answer in the dashboard. The sentence names the database or application, the cluster, and whether the move will also finish by itself. An automatic cutover is stated explicitly, because approving it approves the whole move.
Starting an application-only move is the exception. It is not part of the action cycle and runs when the agent asks. Every later step (cutting over, aborting, destroying the source) does stop and ask.
Watch it
A move takes time. These are the states it goes through:
pending, thenprovisioning: the destination is being built. A full move showsdb_replicatingand thenapp_staginginstead.replicating: a database move is copying and keeping in step. A database restored from backups goes throughrestoringinstead, straight tocompleted.ready(an application or a full move) orsynced(a database): the paused state. Underautothe move passes straight through it. Undermanualit waits here for you.cutover.bridging(an application or a full move): the application is served from the destination and the old cluster still forwards to it. For traffic the move is done. It stays here until you destroy the source.completed,failed, oraborted.
A full move has one more state, failed_forward: it
failed after the database was promoted, which is the one
point that is never rolled back. You can recover by
running the cutover again.
flui migrate app listflui migrate db show <migration-id>flui migrate full list --jsonEach of the three kinds has its own list and show.
list prints the id, the state, the target cluster and
the cutover mode. show adds what is moving and where,
and the error, if there was one. Both take --json.
show for an application or a full move also prints the
bridge: whether it is planned, open or closed, the names
it forwards and their certificates, when the DNS record
moved, and from when it can be closed. When the move goes
by DNS only, it says why.
show for a database or a full move also prints:
Kind:physicalfor a private copy over the Flui network,logicalotherwise;Link: the state of the private link between the two clusters, and whether the two ends have reached each other;Copy: how far the copy has got, and how much is still to catch up once it runs;Fence: when the source stopped taking writes and when the destination was asked to take over;Write pause: how long writes were paused, and what ended the pause;PoolerandCut, when the database has a connection pooler: the pooler’s pause and the clients cut at its deadline (see When the database has a pooler);Next: what is left for you once the move has completed. Flui does not protect the new database with a backup policy for you, so that comes first. A database move also reminds you to point your applications at the new database, and a full move to destroy the source.
When an interrupted cutover can be resumed, show prints
the command to do it.
The Migrations table shows the type, state, source and target, cutover mode and time of each move, plus the actions still available on each row. Those actions are the quickest way to tell where a move is.
A database or full row also shows the kind of copy and the measured write pause, and an application or full row how long the application was stopped while its volumes moved. While a bridge is open, the row says so and from when it can be closed. A completed move has a Next steps list.
migration_list takes an optional type (app, db or
full). Without it, all three kinds come back grouped.
migration_get takes type and id and returns one
migration’s state, cutover mode, error, bridge, kind of
copy, measures and next steps.
Both are in the See migrations permission group, which changes nothing.
Cut over
With --cutover auto there is nothing to do here. The
move cuts over as soon as the destination is ready.
With manual, the move waits at ready (or synced for
a database) until you start the cutover, so you choose
when it happens.
What the cutover does depends on the kind:
- An application is repointed at the destination cluster and its address follows it. It keeps its name and identity throughout. With the bridge, the certificate for its address is prepared on the destination before the cutover; the old cluster then starts forwarding to the new one, its own copy stops, and the DNS record moves. If the application has volumes, it stops while the last changes to its files are copied, then starts on the destination. The move tells you this when you start it, and records how long the pause lasted. If the copy fails, the application starts again on its original cluster.
- A database stops taking writes. After a private copy, Flui waits until the destination has caught up with the last write and promotes it. Otherwise it checks the row counts table by table against the copy, unless you turned that off, and promotes the copy. From then on the source does not take writes and stays that way.
- A full move does both together, and rewrites the application’s connection settings to the new database in the same step.
flui migrate app cutover <migration-id>flui migrate db cutover <migration-id>flui migrate full cutover <migration-id>Use the command that matches the kind of move. You cannot drive the parts of a full move on their own. Flui refuses and tells you to drive the full move instead.
The same command resumes a cutover that was interrupted,
an application cutover that failed after the bridge
opened, and a full move in failed_forward.
A Cutover button appears on the row once the move is
paused, and only then. It runs as soon as you press it.
When a cutover can be resumed (it was interrupted, an
application cutover failed after the bridge opened, or a
full move is in failed_forward), the button reads
Resume cutover.
Use migration_cutover, with type and id. It also
resumes the cutovers listed for the CLI. It is in the
Run migrations group, and it stops and asks you first.
Driving one part of a full move directly is refused, and the agent is told to drive the full move.
What your users see during the cutover
Moving an application. The old cluster keeps answering at the application’s address and forwards everything to the new cluster while the DNS record moves. This is the bridge. A client that still has the old address in its DNS cache reaches the application anyway, so nobody is sent to an empty cluster.
The bridge has limits:
- it runs on the old cluster, so it helps only while that cluster is up;
- while it is open, requests that come through it reach the application from the old cluster’s address, not from the client’s own;
- it is skipped, and the move goes by DNS only, when an address is a wildcard name, has DNS that Flui does not manage, has an IP allow-list, uses a shared certificate, or when the target cluster has no public IPv4 address to forward to. It is also skipped when no valid certificate is ready on the destination at cutover. The move tells you why.
Moving a database on its own. At cutover the source stops taking writes. After a private copy it refuses every connection, so an application still pointing at it loses its database until you point it at the new one.
Moving both with migrate full. Writes pause from the
moment the source stops taking them until the application
on the destination can write again. The move records how
long that was.
With a private copy, --staging live-fenced, the bridge,
and no volumes, the pause is as short as it gets. The new
copy of the application is already running on the
destination against the read-only copy of the database.
At cutover the old cluster starts forwarding to it before
writes stop, so reads keep working the whole time. Writes
pause only from that moment until the destination database
is promoted: a few seconds in our tests. When the database
has a pooler and the application connects through it, those
writes wait instead of failing; see
When the database has a pooler.
With any other
combination the application on the old cluster cannot
write during the cutover, and after a private copy it
cannot reach its database at all, until traffic reaches
the destination.
When the database has a pooler
A managed PostgreSQL installed from the catalog usually has a connection pooler in front of it (see Connect an application to a managed PostgreSQL). When you move it together with its application, writes are not refused at the switch. They wait in the pooler.
At cutover:
- The pooler is paused. New transactions wait in it.
- Transactions already running get a deadline to finish: 5 seconds by default.
- A transaction still open at the deadline is cut. Its client gets an error and must retry.
- The new copy of the database is promoted, and the pooler resumes against it. The waiting transactions go through.
Measured on a move with a private copy, --staging live-fenced and the bridge, writes waited 7.8 seconds with
nothing in flight, and 14.3 seconds when a transaction held
on until the deadline. A probe writing and reading
throughout saw no failed write and no wrong read.
If Flui itself restarts during the pause, writes keep waiting until it is back (59.4 seconds in our test) and none is lost. A client with a short HTTP timeout may give up before then.
Set the deadline with --pause-deadline <seconds>, from 1
to 60, on flui migrate full create, or on
flui migrate full cutover to replace it for a manual
cutover. An agent passes pauseDeadlineSeconds to
migrate_full or migration_cutover. The dashboard has no
field for it and uses the default.
flui migrate full show prints what happened: the Write pause line, for example
7.8s (writes waited in the poolers, none failed), a
Pooler line with when it paused, when it resumed and the
deadline, and a Cut list with each client cut at the
deadline. The dashboard row shows the clients that were
cut.
What this covers, and what it does not:
- Only clients on
FLUI_CONNECTION_URLwait. A client onFLUI_DIRECT_URLtalks to the database directly and sees the switch as before. - Zero refused writes holds in transaction mode. In session mode every client still holds its connection at the deadline, so every client is cut and must reconnect.
- A database without a pooler moves as before. Writes are refused for a few seconds at the switch.
flui migrate apprefuses a database with a pooler. Moving it as an application would leave the pooler behind. Useflui migrate dborflui migrate full.
Abort a move
An abort removes what was built on the destination and leaves the source as it was. Nothing has moved yet, so there is nothing to move back.
You can abort from pending up to the paused state, and
also from failed, so a broken move can be cleaned up. A
private database move can also be aborted during its
cutover, until the destination has been asked to take
over. After that it only goes forward.
Abort is no longer available once traffic has moved. An application move whose bridge is open refuses an abort and tells you to resume the cutover. For a full move the limit comes earlier: once its database has started its cutover, abort is refused. After that point there is no consistent old state to return to, so you finish the cutover instead. The refusal tells you so.
When you abort a database move, Flui closes the link between the two copies but leaves the half-built destination database in place for you to inspect. You have to remove it yourself.
flui migrate app abort <migration-id>flui migrate db abort <migration-id>flui migrate full abort <migration-id>Each asks you to confirm. --yes (-y) skips the
question.
An Abort button appears on rows that can still be aborted, failed ones included. It is not offered while an application move’s bridge is open.
Use migration_abort, with type and id. See
What an agent may do with this
for the permission it needs.
Destroy the source
After the cutover the old copy is still there. With the bridge it forwards to the new cluster; without it, it is drained. Either way it still uses the old cluster’s capacity.
destroy-source frees that capacity. It works on a move
in bridging or completed, it touches only the copy on
the source cluster, and it cannot be undone. When the
bridge is open, it closes the bridge first and the move
becomes completed.
While the bridge is open, destroy-source is refused
until twice the DNS record’s TTL has passed since the
switch, because clients may still hold the old address
until then. The refusal gives you the time. You can close
the bridge earlier on purpose; clients that still resolve
the old cluster then lose the application.
A database move has no destroy step. The source database is left as the cutover left it, not removed. To remove it, remove it as an application, which also deletes its storage. See Remove an application and its data.
flui migrate app destroy-source <migration-id>flui migrate full destroy-source <migration-id>Both ask you to confirm. --yes (-y) skips the
question; use it only in scripts. --close-bridge closes
an open bridge now instead of waiting.
A Destroy source button appears on application and
full migrations in bridging or completed, and it asks
for confirmation before it runs. If the bridge is still
needed, the confirmation says so and the button reads
Close bridge and destroy.
Use migration_destroy_source, with type and id, and
closeBridge: true to close an open bridge before its
time. Asking for db is refused with an explanation, so
the call never silently does nothing.
This tool and migration_abort are in Abort and tear
down migrations, the highest of the three migration
permission groups. A key with only Run migrations can
start and finish a move, but cannot cancel it or destroy
the source.
Both tools can also be missing from the agent’s tool list. Removing things needs two independent conditions: the key must carry that permission depth, and the installation must have destructive operations switched on. If the tool is missing, that is the reason; nothing is broken.
Both stop and ask you before they run.
What an agent may do with this
There are three permission groups, from lowest to highest:
| Group | What it reaches |
|---|---|
| See migrations | migration_list, migration_get. Changes nothing. |
| Run migrations | The above, plus migrate_app, migrate_db, migrate_full and migration_cutover, and reading the applications and clusters involved. |
| Abort and tear down migrations | The above, plus migration_abort and migration_destroy_source. |
A group is granted or refused as a whole, so what you agreed to is exactly what the key carries. Choose what your agent may do explains how to choose one.
Every step that changes something on the destination or removes something on the source stops and asks a person. You approve it in the dashboard, and the agent finds out by trying again. When your agent stops to ask you explains why it works that way.
Where to go next
- Add a cluster and give it capacity: the cluster you are moving to has to exist first.
- The network Flui builds: the network a private database move travels over.
- Put an application on the internet: the DNS zone an application needs before it can move.
- Remove an application and its data: what removing the source database deletes.