Skip to main content

Backup & restore

OtoDock ships two small scripts, backup.sh and restore.sh. They need only Docker and the running stack, so they work for every install method. On a Docker install, download them next to your compose file, and again after each upgrade:

curl -fsSLO https://raw.githubusercontent.com/OtoDock/oto-dock/main/scripts/backup.sh
curl -fsSLO https://raw.githubusercontent.com/OtoDock/oto-dock/main/scripts/restore.sh
chmod +x backup.sh restore.sh

On a source install they are already there, at scripts/backup.sh and scripts/restore.sh.

Taking a backup​

A backup is one command, safe to run while OtoDock is live:

./backup.sh

It writes one folder under backups/ with everything a restore needs: the database, your .env, the agents' files, the SSH keys and the connected accounts' sign-in tokens. Keep that folder as private as .env itself, and copy it off the server, so losing the server doesn't lose it. Installed community tools and skills are not in it: reinstall them from the catalog.

Scheduling and keeping backups​

Run it from cron or a systemd timer, from the install folder:

# every night at 03:15
15 3 * * * cd /srv/otodock && ./backup.sh >> backup.log 2>&1

Each run removes old backups and keeps the newest 14. Only the newest 3 keep the agents' files. OTODOCK_BACKUP_RETAIN changes the 14, and OTODOCK_BACKUP_DIR names another folder, ideally on another disk.

Restoring​

Stop the OtoDock server (leave PostgreSQL running), restore, then start it again:

docker compose stop otodock-proxy # native: sudo systemctl stop otodock-proxy
./restore.sh ./backups/otodock-<version>-<date>-<time>
docker compose up -d # native: sudo systemctl start otodock-proxy

The script asks you to type yes, then replaces the database, the agents' files, the SSH keys and the sign-in tokens with the backup's. OtoDock brings the database up to date at its next start. If the script refuses, it says why and what to do.

Moving to a new server​

  1. In an install folder on the new server, put the old install's docker-compose.yml and docker-compose.phone.yml, and the backup's env file as .env. Change the ports and DASHBOARD_PUBLIC_URL if they differ. If you lost the old server, download the two compose files from https://raw.githubusercontent.com/OtoDock/oto-dock/v<version>/, with the version in the backup folder's name.
  2. On Ubuntu 24.04 or newer, download scripts/setup-apparmor-userns.sh from the same address and run it with sudo.
  3. Run docker compose up -d, then docker compose stop otodock-proxy.
  4. Copy the backup folder over and run ./restore.sh on it.
  5. Run docker compose up -d.

The connected accounts come back with it, since the backup's keys came along in .env.

Next steps​