Self-hosting
Move Leantime to a new server
- Self-hosted only
At a glance
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
- A terminal on the old server
- A terminal on the new server
- Your DNS provider, to point your domain at the new server
- 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.
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.
Before you start
Section titled “Before you start”- Use the same Leantime version on both servers. Move first, upgrade afterwards. In Docker, set
LEAN_VERSIONin.envto the version you run now (for exampleLEAN_VERSION=3.14.0). - Keep the old server untouched until you’ve checked the new one.
- Tell your team when Leantime will be unavailable.
Move a Docker installation
Section titled “Move a Docker installation”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.
On the old server
Section titled “On the old server”-
Stop Leantime, but keep the database running:
Terminal window docker compose stop leantime -
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.sqlThe file ends with
-- Dump completed on …when it’s complete. -
Archive the file volumes. Find their names with
docker volume ls; they start with your folder name, likedocker-leantime_userfiles. For each ofuserfiles,public_userfilesandplugins:Terminal window docker run --rm -v docker-leantime_userfiles:/data -v "$PWD":/backup alpine \tar czf /backup/userfiles.tar.gz -C /data . -
Copy everything to the new server:
leantime.sql, the three.tar.gzfiles,.envanddocker-compose.yml. For example:Terminal window scp leantime.sql *.tar.gz .env docker-compose.yml you@new-server:~/docker-leantime/
On the new server
Section titled “On the new server”-
Create the containers and volumes without starting Leantime, and start the database:
Terminal window cd ~/docker-leantimedocker compose up -d leantime_dbdocker compose create leantimeWait until
docker compose psshows the database ashealthy. -
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 -
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 -
Start Leantime:
Terminal window docker compose up -dThe 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.
-
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_URLin.envand rundocker compose up -dagain.
Move a package installation
Section titled “Move a package installation”On the old server
Section titled “On the old server”-
Export the database:
Terminal window mysqldump --no-tablespaces --single-transaction -u <db user> -p <db name> > leantime.sql -
Copy these from the Leantime folder:
config/.env: your settingsuserfiles/: uploaded filespublic/userfiles/: logo and public imagesapp/Plugins/: installed plugins
On the new server
Section titled “On the new server”-
Install the same Leantime version from its release package, as in Install from the release package, but don’t run the installer.
-
Create an empty database and user, then import:
Terminal window mysql -u <db user> -p <db name> < leantime.sql -
Put the copied folders and
config/.envback in the same places. Update the database settings in.envif they changed. Keep.envreadable only by the web server user:sudo chown www-data:www-data config/.env && sudo chmod 640 config/.env. -
Make the folders writable by the web server user (often
www-data):storage/,bootstrap/cache/,userfiles/,public/userfiles/andapp/Plugins/. -
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.
-
Point your domain at the new server, and update
LEAN_APP_URLif the address changes.
How do I check that everything moved?
Section titled “How do I check that everything moved?”- 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.
Something’s wrong after the move
Section titled “Something’s wrong after the move”- You can’t log in: check
LEAN_APP_URLandLEAN_SESSION_SECUREagainst 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.
Can I move to Leantime Cloud instead?
Section titled “Can I move to Leantime Cloud instead?”Yes. We can migrate a self-hosted instance to Leantime Cloud for a small fee. Ask through the chat on leantime.io.
Related
Section titled “Related”Was this page helpful?
Thanks, glad it helped.
Thanks for telling us. What was missing?
