---
title: Back up and restore the MikroWizard server
description: What to back up on the MikroWizard server, including the encryption key, and how to restore it.
url: "https://mikrowizard.com/docs/backup-restore-mikrowizard-server/"
updated: "2026-11-25"
category: "Install & Upgrade"
---

# Back up and restore the MikroWizard server

Free Pro

A MikroWizard server keeps its data in two places: the **PostgreSQL database** (inside the `MikroWizard-postgre` container) and **files on the host**, mostly under `/opt/mikrowizard`. A complete backup needs both.

 The database lives in an unnamed Docker volume of the `MikroWizard-postgre` container. Removing that container, running the installer again, or `docker volume prune` can lose it. Always keep a database dump.

## What to back up

| What | Where (default) | Why | Needed? |
| --- | --- | --- | --- |
| Database | `MikroWizard-postgre` container, database `MikroWizardDB` | Devices, users, groups, permissions, settings, tasks, logs, vault entries, PAM policies, customer data | **Yes** |
| `server-conf.json` | `/opt/mikrowizard/server-conf.json` | The encryption keys `PYSRV_CRYPT_KEY` and `PYSRV_KEK`, plus the addon tokens. Without these keys, the device passwords and vault entries in the database can't be decrypted. | **Yes** |
| Router configuration backups | The backup folder chosen at install (`/opt/mikrowizard/backup`, older installs `/opt/mikrowizard/backups`) | Every backup file and configuration version. The database only points to these files. | **Yes** |
| Session recordings (Pro) | `/opt/mikrowizard/terminal_recordings`, `/opt/mikrowizard/webfig_recordings` | Replays of SSH, RDP, VNC, WebBox and WebFig sessions | Yes, if you keep recordings for audits |
| SSL certificates | `/opt/mikrowizard/ssl`, `nginx-ssl-server.conf`, `nginx-ssl-redirect.conf` | Let's Encrypt account and certificates, or your own certificate | Yes, if you use HTTPS |
| Terminal Gateway (Pro) | `/opt/mikrowizard/terminal-gateway/gateway.env` | Gateway settings and its API token | Yes, if installed on this server |
| WireGuard addon (Pro) | `/opt/mikrowizard/wireguard` | The server's **private key**, the addon token and peer state. With a new key, every peer's configuration has to be replaced. | Yes, if installed |
| MikroSpeed addon | `/opt/mikrowizard/speedtest` | The addon token | Yes, if installed |
| Firmware files | The firmware folder chosen at install (`/opt/mikrowizard/firmwares`) | Downloaded RouterOS packages | Optional: they can be downloaded again |

Not needed: `drives` (temporary per-session drives of the Terminal Gateway), `logs` (service log files), `wireguard-addon` (addon program files, reinstalled by its installer), `recreate-ssl.sh` (created again by MikroWizard), `front-update-last-check`, `crontab` and old `*.bak` / `-b` copies. The Redis container holds only temporary data such as sign-in sessions, queues and the state of running jobs.

### Check your folders

Your backup and firmware folders may not be the defaults. Show the folders the backend container uses:

```
sudo docker inspect -f '{{range .Mounts}}{{.Source}} -> {{.Destination}}{{println}}{{end}}' mikroman
```

The folder mounted on `/backups` holds the router backups, the one on `/firms` the firmware files.

Show the database user and name:

```
sudo grep -E '"PYSRV_DATABASE_(USER|NAME)"' /opt/mikrowizard/server-conf.json
```

## Back up

Run on the MikroWizard server. Replace `DBUSER` with the database user shown above and `MikroWizardDb` with database DATABASE_NAME . If your backup folder is outside `/opt/mikrowizard`, add it at the end of the `tar` command.

```
sudo mkdir -p /root/mw-backup
sudo sh -c 'docker exec MikroWizard-postgre pg_dump -U DBUSER -Fc MikroWizardDB > /root/mw-backup/MikroWizardDB.dump'
sudo tar czf /root/mw-backup/mikrowizard-files.tgz   --exclude=/opt/mikrowizard/drives --exclude=/opt/mikrowizard/logs   /opt/mikrowizard
```

To leave out firmware files, add `--exclude=/opt/mikrowizard/firmwares`.

Check the result with `sudo ls -lh /root/mw-backup`. A dump of only a few kilobytes means it failed.

Copy `/root/mw-backup` to another machine and keep it safe: it contains the encryption keys and device credentials.

 Back up regularly, for example with a nightly cron job on the host, and keep several copies. The database dump can be taken while MikroWizard runs.

## Restore

Restore onto the **same MikroWizard version**. A new installation installs the latest version, so upgrade the old server to the latest version before you take the backup.

1. Install MikroWizard on the target server: see [Install MikroWizard](https://mikrowizard.com/docs/install-the-mikrowizard/). Use the same backup and firmware folders as before.
2. Copy the backup to `/root/mw-backup` on the target server and stop the backend:

```
sudo docker stop mikroman
```

1. Keep a copy of the new configuration file, then restore the files:

```
sudo cp /opt/mikrowizard/server-conf.json /root/server-conf.new.json
sudo tar xzpf /root/mw-backup/mikrowizard-files.tgz --numeric-owner -C /
```

1. The restored `server-conf.json` has the old keys, which you need, but also the old database and Redis passwords. Put the new installation's database user and passwords back into it:

```
sudo python3 -c '
import json
p = "/opt/mikrowizard/server-conf.json"
new = json.load(open("/root/server-conf.new.json"))
conf = json.load(open(p))
for k in ("PYSRV_DATABASE_USER", "PYSRV_DATABASE_PASSWORD", "PYSRV_REDIS_PASSWORD"):
    conf[k] = new[k]
json.dump(conf, open(p, "w"), indent=4)
'
sudo chmod 600 /opt/mikrowizard/server-conf.json
```

1. Restore the database. Replace `DBUSER` with the database user of the **new** installation and `MikroWizardDb` with database DATABASE_NAME :

```
sudo sh -c 'docker exec -i MikroWizard-postgre pg_restore -U DBUSER -d MikroWizardDB --clean --if-exists --no-owner --no-acl < /root/mw-backup/MikroWizardDB.dump'
```

1. Start MikroWizard again:

```
sudo docker restart mikrofront
sudo docker start mikroman
```

1. Addons: run the installer of each addon you used: [Terminal Gateway](https://mikrowizard.com/docs/installing-terminal-gatway-addon/), [WireGuard](https://mikrowizard.com/docs/install-mikrowizard-wireguard-docker-server/), [MikroSpeed](https://mikrowizard.com/docs/installing-mikrospeed-addon/). They use their restored folders and write their settings into `server-conf.json`. The WireGuard addon keeps the restored private key, so peers keep working.
2. Schedules: open each scheduled task in the [Task Planner](https://mikrowizard.com/docs/task-planner/) and save it again. Do the same for the Password Vault settings and for Sync & Clone profiles that run on a schedule. These schedules are kept inside the backend container, not in the database, so a new container doesn't have them until they are saved again.
3. Sign in and check: devices come online, **Password Vault › Reveal** shows a password (this proves the keys match), backups and recordings open.

## Common problems

| Problem | Cause and fix |
| --- | --- |
| The backend doesn't start after the restore | Wrong database or Redis password in `server-conf.json`. Repeat step 4. |
| Devices fail with authentication errors, vault passwords can't be revealed | `server-conf.json` is not the one from the backup, so the keys don't match the database. |
| Backups are listed but don't open | The router backup folder wasn't restored, or the backend uses another folder. Check with `docker inspect` as above. |
| Scheduled tasks don't run | Save each task again (step 8). |
| `pg_restore` reports an unsupported version | The dump is from a newer PostgreSQL than the target. Use the same or a newer PostgreSQL image on the target. |

## Next step

- [Move MikroWizard to a new server](https://mikrowizard.com/docs/move-mikrowizard-to-new-server/)
