Skip to content
Display

Display

Star12.2k

Self-hosting

Move Leantime to a new server

  • Self-hosted only

At a glance

Time30–60 min

LevelSome experience

You need

  • Access to both servers
  • A time when nobody uses Leantime (changes made during the move are lost)
  • Access to your domain's DNS settings, if the address moves with it

Where you'll work

  1. A terminal on the old server
  2. A terminal on the new server
  3. Your DNS provider, to point your domain at the new server
  4. Leantime on the new server, to check that everything moved

At the end

Leantime running on the new server with all projects, to-dos, files, users and plugins. Large file folders take longer to copy.

Markdown

Moving Leantime means copying three things to the new server: the database, the uploaded files and plugins, and your settings. Then you start the same Leantime version there and point your domain at it.

  • Use the same Leantime version on both servers. Move first, upgrade afterwards. In Docker, set LEAN_VERSION in .env to the version you run now (for example LEAN_VERSION=3.14.0).
  • Keep the old server untouched until you’ve checked the new one.
  • Tell your team when Leantime will be unavailable.

These commands assume the official docker-compose.yml, where the database service is called leantime_db. Run them in the folder that holds docker-compose.yml.

  1. Stop Leantime, but keep the database running:

    Terminal window
    docker compose stop leantime
  2. Export the database:

    Terminal window
    docker compose exec -T leantime_db sh -c 'exec mysqldump --no-tablespaces --single-transaction -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' > leantime.sql

    The file ends with -- Dump completed on … when it’s complete.

  3. Archive the file volumes. Find their names with docker volume ls; they start with your folder name, like docker-leantime_userfiles. For each of userfiles, public_userfiles and plugins:

    Terminal window
    docker run --rm -v docker-leantime_userfiles:/data -v "$PWD":/backup alpine \
    tar czf /backup/userfiles.tar.gz -C /data .
  4. Copy everything to the new server: leantime.sql, the three .tar.gz files, .env and docker-compose.yml. For example:

    Terminal window
    scp leantime.sql *.tar.gz .env docker-compose.yml you@new-server:~/docker-leantime/
  1. Create the containers and volumes without starting Leantime, and start the database:

    Terminal window
    cd ~/docker-leantime
    docker compose up -d leantime_db
    docker compose create leantime

    Wait until docker compose ps shows the database as healthy.

  2. Import the database:

    Terminal window
    docker compose exec -T leantime_db sh -c 'exec mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' < leantime.sql
  3. Restore the file volumes, one per archive (check the names with docker volume ls):

    Terminal window
    docker run --rm -v docker-leantime_userfiles:/data -v "$PWD":/backup alpine \
    tar xzf /backup/userfiles.tar.gz -C /data
  4. Start Leantime:

    Terminal window
    docker compose up -d

    The image runs Leantime’s scheduled jobs itself, so don’t add a cron job. Keep Leantime stopped on the old server, so the jobs don’t run on both servers and send some emails twice.

  5. Point your domain at the new server (DNS), and set up your reverse proxy and HTTPS there. If Leantime’s address changes, update LEAN_APP_URL in .env and run docker compose up -d again.

  1. Export the database:

    Terminal window
    mysqldump --no-tablespaces --single-transaction -u <db user> -p <db name> > leantime.sql
  2. Copy these from the Leantime folder:

    • config/.env: your settings
    • userfiles/: uploaded files
    • public/userfiles/: logo and public images
    • app/Plugins/: installed plugins
  1. Install the same Leantime version from its release package, as in Install from the release package, but don’t run the installer.

  2. Create an empty database and user, then import:

    Terminal window
    mysql -u <db user> -p <db name> < leantime.sql
  3. Put the copied folders and config/.env back in the same places. Update the database settings in .env if they changed. Keep .env readable only by the web server user: sudo chown www-data:www-data config/.env && sudo chmod 640 config/.env.

  4. Make the folders writable by the web server user (often www-data): storage/, bootstrap/cache/, userfiles/, public/userfiles/ and app/Plugins/.

  5. Move the scheduled jobs. Only one server may run Leantime’s jobs, or people get some emails twice. On the old server, remove the cron job from the crontab and stop Leantime there (or point its web server away from Leantime). Removing the cron job alone isn’t enough: anyone who still reaches the old server while the domain switches over makes their browser run the jobs there. Then add the cron job to the new server, as in How do I run the scheduled jobs?. Without it, notification emails on the new server wait until someone opens Leantime.

  6. Point your domain at the new server, and update LEAN_APP_URL if the address changes.

  • Log in with your usual account.
  • Open a to-do with an attachment and open the file.
  • Check that your logo shows in the header.
  • Open My Apps and check your plugins are installed and enabled.
  • Check that emails still arrive, for example with a password reset or a comment notification.

When all of that works, you can shut down the old server. Keep leantime.sql and the archives as a backup.

  • You can’t log in: check LEAN_APP_URL and LEAN_SESSION_SECURE against the new address. See Common issues.
  • Attachments or the logo are missing: a file volume or folder wasn’t restored, or isn’t writable.
  • “Update Database” appears: the new server runs a newer Leantime version than the old one. Back up, then click Update Now! to continue with that version.

Yes. We can migrate a self-hosted instance to Leantime Cloud for a small fee. Ask through the chat on leantime.io.

Was this page helpful?