Move your Otto server to a new machine
Copy everything your Otto server holds to a new machine and switch over to it: run one command on your Mac and answer its questions. The old server is left as it was until you delete it.
Before you start
- The new server runs a fresh Ubuntu 24.04, Debian 12 or Debian 13. Your Mac can SSH to it as
root, with its own key or with root's password: when the key is not accepted, the move asks for the password once and adds the key. - Your Mac has a checkout of the Otto repository.
- Your Mac reaches the old server through an alias in
~/.ssh/config, with aHostNameline. The default alias isotto-vps. - You can change the DNS records of the domain names your Otto server uses.
Below, replace NEW_IP with the new server's IP address, OLD_IP with the old one's, and example.com with your domain. Your sessions are paused from the start of the move until its end. The move leaves out what an install or a build makes again, such as node_modules; each session reinstalls its dependencies when it next starts.
Before you move
Do this once, a day before the move.
-
Give the server a name
At your DNS provider, add an A record
vps.example.compointing atOLD_IP. -
Point your Macs at the name
On every Mac, in
~/.ssh/config, set theHostNameline underHost otto-vps:HostName vps.example.comThen run
ssh otto-vps trueonce, and answeryesif it asks: it is the same server under its new name. From now on, your Macs follow the server through DNS. -
Lower the TTLs
At your DNS provider, set the TTL of every domain name your server uses, and of
vps.example.com, to 300 seconds. To list the names:ssh otto-vps sudo bash /opt/otto/deploy/session-host/server-move.sh namesThe old TTL must run out before the new one counts, so do this a day ahead. A short TTL makes the switch take minutes instead of hours.
-
Check the new server (optional)
scp deploy/session-host/server-move.sh root@NEW_IP: ssh root@NEW_IP bash server-move.sh preflightIt prints one
PASS,WARNorFAILline per check, and changes nothing. Fix eachFAIL. The move runs the same check first anyway.
Move
-
Start the move
On your Mac, in your Otto checkout, run:
bash deploy/session-host/server-move.shIt asks, each with a default in brackets that Enter takes:
- the alias your Mac reaches the old server with,
otto-vpsby default; - the new server's IP address,
NEW_IP; - if your alias still has an IP address, whether to give the server a name. Say yes, and take
vps.example.comor type your own.
It then shows the steps as a checklist, with how long each takes, and warns about a TTL still above 600 seconds. Answer
yto go ahead. Your sessions pause from step 3 until step 10. - the alias your Mac reaches the old server with,
-
Type root's password, if it asks
Only when the new server does not take your Mac's key yet. Type its root password once; the move adds your Mac's key with it, and nothing asks again.
-
Wait for the copy and the import
The move ticks off each step as it finishes. It checks the new server, drains and exports the old one, copies the export from server to server, and installs Otto on the new server. This takes about half an hour. Each session is paused once its turn is over, with its conversation kept. A session still busy after 5 minutes is interrupted, unless it is in a git operation or an Otto vault edit, which is waited for up to 30 more minutes. The old server is fenced: Otto stays off there, even after a reboot.
-
Point your domain names at the new server
When it says
▲ Your turn, it lists the domain names your server uses,vps.example.comamong them. At your DNS provider, point each one atNEW_IP: change its A record, and remove any AAAA record that points at the old server.The move checks every 30 seconds and carries on by itself once every name gives the new address. You can press Ctrl-C and run it again later.
-
Flush your Mac's DNS cache, if it asks
If your Mac still has the old address cached, the move offers to flush it. Answer
yand type your Mac's password forsudo. Otherwisessh otto-vpscould reach the old, fenced server for a while. -
Resume your sessions: the point of no return
The move has verified the new server and stopped the old one's website. Until now you can still go back to the old server, losing nothing. Once your sessions resume on the new server, their work happens there only, and going back would lose it. When you answer
y, the move records this on the old server, whoseundo-exportthen refuses.It resumes your sessions one at a time, each told it was paused for maintenance, and reports how many resumed, naming any that did not yet. A background job a session was waiting on, such as a dev server, ended with the old server: the session is told to run it again.
-
Keep or delete the export's copies
The export is still on both servers, and it holds your keys. Answer
nto keep it for a few days; the move prints the two commands that delete it. Answeryto delete it now. -
Reconnect the CI runner
Skip this step if you never registered a self-hosted runner. Otherwise, on GitHub open your repository's Settings → Actions → Runners → New self-hosted runner, copy the
--tokenvalue, and run the command the move printed:ssh -t otto-vps sudo bash /opt/otto/deploy/session-host/vps-deploy.sh runner-registerPaste the token when asked. Then remove the old, offline runner on the same GitHub page.
You're done when it says Moved. Your other Macs follow by themselves. After a few days on the new server, delete the old server.
Without a server name, the move changes only this Mac's HostName, to NEW_IP, and keeps a backup. Change it by hand on your other Macs. If Otto's Settings → Session hosts names the server by its address, change it there too.
Carry on or start over
Each step runs once. If the move stops, or you press Ctrl-C, fix what it says and run bash deploy/session-host/server-move.sh again: it offers to carry on, and opens at the step it stopped at. Its progress is kept in ~/.otto/server-move/otto-vps/ on your Mac.
To start over, answer n to carrying on and y to starting over, or add --restart. An export that was already made on the old server is kept.
Move with flags (scripted)
The same move, with the answers given as flags. To see the plan first, changing nothing:
bash deploy/session-host/server-move.sh move NEW_IP --dry-run
Then run it:
bash deploy/session-host/server-move.sh move NEW_IP --from otto-vps --server-name vps.example.com
--yes answers yes to every question but deleting the export's copies, which it keeps. Root's password can come from --password-file or OTTO_MOVE_PASSWORD. Every option is in the reference.
Move step by step (fallback)
The same move, one command at a time, run on the servers. Use it when you can't run move from a Mac. Below, replace SERVER and NEW_IP with your own values.
SERVER: the name your Mac uses to SSH to your Otto server, from~/.ssh/config.NEW_IP: the IP address of the new server. It runs a fresh Ubuntu 24.04, Debian 12 or Debian 13, and you can SSH to it asroot.- You can change the DNS records of the domain names your Otto server uses.
Do Before you move first. Your sessions are paused from step 2 until step 7. To see what step 2 will copy and whether it fits on the old server's disk, first run it with --dry-run. It leaves out what an install or a build makes again, such as node_modules; each session reinstalls its dependencies when it next starts.
-
Check the new server
scp deploy/session-host/server-move.sh root@NEW_IP: ssh root@NEW_IP bash server-move.sh preflight --need-bytes BYTESReplace
BYTESwith theEXPORT_BYTESvalue thatexport --dry-runprints on the old server, or leave--need-bytesout. Fix eachFAILbefore you go on. -
Export the old server
ssh SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh export --drainIt first drains the server: each session is paused once its turn is over, with its conversation kept, and nothing new starts. A session still busy after 5 minutes is interrupted, unless it is in a git operation or an Otto vault edit, which is waited for up to 30 more minutes. Then it exports, and fences the server so Otto stays off there. It ends with
export done.If a session is still mid-turn when the wait ends, it refuses. Let that session finish, or stop it, and run the command again.
-
Copy the export to the new server
On your Mac, through your Mac:
scp -3 -r SERVER:otto-move root@NEW_IP: -
Import it on the new server
ssh root@NEW_IP bash otto-move/server-move.sh importIt ends with
import verifiedand lists the domain names your server uses. The new server now answers with the old one's SSH host keys. -
Point your domain names at the new server
At your DNS provider, point each name the import listed, and the server's own name, at
NEW_IP: change its A record, and remove any AAAA record that points at the old server. -
Check the new server through your Mac
If your alias uses the server's name, it follows DNS. Otherwise, on each Mac, change the
HostNameline underHost SERVERtoNEW_IP, and change Otto's Settings → Session hosts if it names the server by its address. Then run:ssh SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh verifyRun it again until it ends with
verified; DNS changes can take a while to arrive. -
Resume your sessions
This is the point of no return: from here on, going back to the old server would lose what the sessions do on the new one. First stop the old server's website and record the move there, so its
undo-exportrefuses:ssh -o HostName=OLD_IP SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh stop-web ssh -o HostName=OLD_IP SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh moved-to NEW_IPThe drain moved with the server, so the new server still starts nothing. Undrain it and resume what the drain paused:
ssh SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh undrainThe sessions resume one at a time, and each is told it was paused for maintenance. It reports how many resumed. Or click Undrain in Otto's Settings → Session hosts, with Resume the sessions the drain paused ticked.
-
Reconnect the CI runner
Skip this step if you never registered a self-hosted runner. Otherwise, on GitHub open your repository's Settings → Actions → Runners → New self-hosted runner, copy the
--tokenvalue, and run:ssh -t SERVER bash /opt/otto/deploy/session-host/vps-deploy.sh runner-registerPaste the token when asked. Then remove the old, offline runner on the same GitHub page.
You're done. After a few days on the new server, delete the old server and the otto-move folder on the new one. The folder holds your keys.
If something goes wrong
If the move stops with an error, fix what it says and run it again. It carries on where it stopped.
Until you delete it, the old server still holds everything. Before your sessions resume on the new server, you can go back to it losing nothing. To go back, point DNS, the server's name included, at the old server's address again. Without a server name, change HostName back too: the move kept a backup of ~/.ssh/config next to it. Then run, with your alias for SERVER:
ssh SERVER sudo bash /opt/otto/deploy/session-host/server-move.sh undo-export
It lifts the fence, starts Otto there again, its website included, and lifts the drain, resuming the sessions it paused one at a time.
Once your sessions have resumed on the new server, undo-export refuses: the old server would come back as it was at the export, without the work done since. Add --force only if you mean to lose that work.