Data & Backup
Everything the server stores lives under one directory — dataDir, by default /var/lib/code/data (userland install: ~/.local/share/code/data). Plain files, no database.
What's in there
| Contents | |
|---|---|
device/ | Bound machines and their (hashed) web passwords — your "accounts" |
| sessions & messages | Chat history for every past session |
| settings | Server-side preferences |
cert/cache/ | HTTPS certificates and the Let's Encrypt account key |
Your code and Claude Code credentials are not here — those never leave your own computer. The server holds only relay data and history.
Backup
Two files matter: the data directory and the config.
sudo systemctl stop code-server
sudo tar czf code-backup-$(date +%F).tgz /var/lib/code/data /etc/code.yaml
sudo systemctl start code-server(Stopping isn't strictly required, but it guarantees a consistent snapshot and only takes a second.)
Move to a new server
- Install the server on the new machine (Install the Server).
- Stop it, restore the backup into the same paths,
chown -R code:code /var/lib/code(containers:10001:10001), start it. - Point your domain's DNS at the new IP.
Agents and browsers reconnect by domain name, so bindings, passwords, and history all carry over — nothing needs to re-bind. The certificate cache moves with the data, so no re-issuing either.
Reset
Want a factory reset? Stop the server and delete the data directory — all machines, passwords, and history are gone, and every agent must bind again. Certificates are also re-issued on start; if you reset repeatedly you may hit the Let's Encrypt rate limit (see HTTPS & Domain), so consider keeping cert/cache:
sudo systemctl stop code-server
sudo find /var/lib/code/data -mindepth 1 -maxdepth 1 ! -name cert -exec rm -rf {} +
sudo systemctl start code-server