Upgrading an existing Intercity installation to the new installer
Tags: development, intercity, installer, dokku
Published: 2019-05-06 18:44:36

---
title: Upgrading an existing Intercity installation to the new installer
published: true
tags: Development,Intercity,Installer,Dokku
canonical_url: https://www.michielsikkes.com/upgrading-an-existing-installation-to-the-new-intercity-installer/
---

Two days ago, I posted about the updated and simpler installation method I shipped into Intercity's master branch: [Updated installing Intercity to a single command](https://dev.to/firmhouse/updated-installing-intercity-to-a-single-command-3ah). The new command works great on a fresh new Ubuntu LTS. 🕺💃

However, if you've previously installed Intercity via the `intercity-server` command as described in the previous [docs/installation.md](https://github.com/intercity/intercity-next/blob/ba483a3ddbb63555834963abbff9efc88b04922e/doc/installation.md), you'll have to perform some additional steps as the database setup is different. You'll have to migrate your current database into the database of the new installation. You definitely don't want to loose al your precious app configuration settings and secrets!

What you'll have to do is the following. I'll explain each step in details below.

1. Export the current Intercity database via `pg_dump`.
2. Stop your current Intercity installation.
3. Install the new Intercity via the new installation procedure.
4. Import the database from your previous installation into the new one.

Before you perform the above steps: make sure you have a backup of your server. For example by using the backups/snapshots feature of your VPS provider or Cloud.

You can also copy the directory `/var/intercity/shared/postgres_data` to `/var/intercity/shared/postgres_data_backup` for example:

<!--kg-card-begin: code-->
```
$ sudo cp -r /var/intercity/shared/postgres_data /var/intercity/shared/postgres_data_backup
```
<!--kg-card-end: code-->

Ok, so here we go:

## Export the current database

Look up the Docker container ID of your current Intercity installation:

<!--kg-card-begin: code-->
```
$ sudo docker ps
```
<!--kg-card-end: code-->

You should see something like this:

<!--kg-card-begin: code-->
```
db76d2869d40	local_intercity/app	"/sbin/boot"
```
<!--kg-card-end: code-->

"db76d2869d40" is the container ID of your current Intercity installation. Use it in the next few commands to access a shell in that running container, export the database, and bring it back to your host system:

<!--kg-card-begin: code-->
```
$ sudo docker exec -it db76d2869d40 bash
(container) # su intercity
(container) $ cd /home/intercity
(container) $ pg_dump -U intercity -d intercity -f intercity.sql
(container) $ exit
(container) # cp /home/intercity/intercity.sql /shared
(container) # exit
```
<!--kg-card-end: code-->

You have now succesfully exported the database from your current Intercity environment into a file `intercity.sql` in `/var/intercity/shared` on your host system. We'll use this file in one of the next steps to import into your new Intercity installation.

## Stop your current installation

You can safely stop your current Intercity with the following command, using the container ID you fetched in the previous steps:

<!--kg-card-begin: code-->
```
$ sudo docker stop db76d2869d40
```
<!--kg-card-end: code-->
## Install Intercity via the new installation procedure
<!--kg-card-begin: code-->
```
$ mkdir intercity
$ wget https://raw.githubusercontent.com/intercity/intercity-next/master/scripts/bootstrap.sh
$ sudo bash bootstrap.sh
```
<!--kg-card-end: code-->

After a few minutes your installation is running and the "Create your first user" screen should be visible on the domain name you've configured. Please verify that you see the "Create your first user" screen to ensure your new installation is fully booted up!

## Import your Intercity database

Now we're going to import the `intercity.sql` database into the new Intercity installation.

Run the following commands to do so:

<!--kg-card-begin: code-->
```
$ sudo -s
# cat /var/intercity/shared/intercity.sql | docker-compose exec db psql -U postgres -d intercity
```
<!--kg-card-end: code-->

You should see a lot of output in your terminal. This indicates that the database is being imported. You probably see a lot of errors in this output, telling you relations or indexes already exist. This is fine, as the clean bootstrapped database from the new Intercity install already created those. This command is now only importing the data.

To check if the import was succesful: head over to the URL that your Intercity installation is hosted on. Instead of the "Create your first user" screen, you should now see the regular login screen again. If you see the login screen: import succesful!

<!--kg-card-begin: hr-->
* * *
<!--kg-card-end: hr-->

Awesome! I hoped this procedure worked for you. If not, or if you're getting errors: let me know!