# Manually update dhis2 database and java on LXC

**URL:** <https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253>\
**Category:** Server Administration - Administration-du-Serveur\
**Tags:** server-admin\
**Created:** [2 August 2023 06:48 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253 "2023-08-02T06:48:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [2 August 2023 06:48 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/1 "2023-08-02T06:48:56Z")

</div>

Dear community,

Following these steps, we had configured the Dhis2 server with LXC containers for two years. [GitHub - bobjolliffe/dhis2-tools-ng: Next generation dhis2-tools](https://github.com/bobjolliffe/dhis2-tools-ng).

On this server, we now want to update the war file, the database, and Java 11. Please let me know if this is feasible. If yes then how can we do that.  
Also, what if we want to add postgres extension btree\_gin and pg\_trgm along with postgis.

Thanks

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [2 August 2023 18:04 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/2 "2023-08-02T18:04:51Z")

</div>

Hi @MohinderS

Welcome back to the community. Many in the community have experience with servers so hopefully you’ll get a complete answer from your fellow community members.

> [@MohinderS](#):
>
> we now want to update the war file, the database

May I ask what version of dhis2 are you upgrading from and to which version?

Thanks!

---

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [2 August 2023 20:56 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/3 "2023-08-02T20:56:20Z")

</div>

Dear @Gassim,

Thanks for your response.

Currently we have two applications 2.34 and version 2.36 on different servers. We want to update to version 2.38.

Thanks

---

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [4 August 2023 04:42 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/4 "2023-08-04T04:42:18Z")

</div>

Hello there,

Can anyone guide me please.

Thanks

---

<div class="post-metadata">

**Author:** ![Gerald\_Thomas](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gerald_thomas/32/43379_2.png) [@Gerald\_Thomas](https://community.dhis2.org/u/Gerald_Thomas)\
**Post date:** [5 August 2023 07:32 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/5 "2023-08-05T07:32:51Z")

</div>

Mohinder,

I will recommend you do the following rather than doing it manually:

1. creating backups of the database or databases.
2. Make sure to document all the additional apps you have installed.
3. Run `./delete_all.sh` to remove all containers.
4. Proceed to git pull the new dhis2-tool-ng version,
5. Verify the lines again in configs/containers.json to reflect your fqdn, email, and tz:
6. Run `sudo ./lxd_setup.sh` to set up the main instances monitor, postgres, and proxy
7. Run ‘sudo ./ssl\_setup.sh’  
5, Execute the commands to create your instance again, and then restore the databases.

Please note: The script will automatically include all the new Postgres extensions that you’ve previously listed.

---

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [7 August 2023 05:26 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/6 "2023-08-07T05:26:21Z")

</div>

Thanks @Gerald_Thomas for your response.  
Sure, We’ll follow up the given steps.

---

<div class="post-metadata">

**Author:** ![tkipkurgat](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/tkipkurgat/32/39135_2.png) [@tkipkurgat](https://community.dhis2.org/u/tkipkurgat)\
**Post date:** [7 August 2023 16:16 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/7 "2023-08-07T16:16:28Z")

</div>

You can also try out the newly developed [dhis2-server-tools](https://github.com/dhis2/dhis2-server-tools), which are based on Ansible. However, please follow Gerald’s instructions closely. We have a video recording of one of our Thursday server admin calls that you might find helpful:

[dhis2 setup with dhis2-server-tools](https://www.youtube.com/watch?v=Np5cKeRpT18&list=PLPyA5ikzdomky1OkfraVffxn8U4LFGzfJ&index=2)

---

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [8 August 2023 04:50 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/8 "2023-08-08T04:50:56Z")

</div>

Thanks @tkipkurgat , its very helpful.  
One time setup is fine, but will face issue while updating the current dhis2 and package versions.

---

<div class="post-metadata">

**Author:** ![tkipkurgat](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/tkipkurgat/32/39135_2.png) [@tkipkurgat](https://community.dhis2.org/u/tkipkurgat)\
**Post date:** [8 August 2023 07:36 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/9 "2023-08-08T07:36:15Z")

</div>

To ensure a smooth upgrade of your entire stack, the recommended approach would be to create a database backup first. Once the backup is secure, you can proceed with deleting the existing components and then build the stack anew. While you could perform these tasks manually, it might become more complex. It’s best to handle the database upgrade first and then proceed with upgrading the DHIS2 instance. This way, you can minimize any potential risks and ensure a seamless upgrade process.

**Manually upgrading database**  
Here are some general recommendations and steps to follow when upgrading your PostgreSQL database, specifically to version 13, which has been tested with DHIS2:

1. Backup your database: Take a complete backup of your existing database to ensure you have a copy of the data in case anything goes wrong during the upgrade process. Test the backup to ensure it works fine and consider saving it offsite as a fallback option

2. Create a new database container: Set up a new database container running PostgreSQL 13 on your server. Make sure your storage can accommodate running two databases in parallel.

3. Plan for downtime: Prepare for the required downtime during the upgrade process. Inform users and stakeholders about the scheduled maintenance window and the expected duration of the upgrade.

4. Disable external connections: Temporarily disable external connections to the database during the upgrade. This prevents unwanted interactions or data inconsistencies while the upgrade is in progress.

5. Restore the backup: Follow the official PostgreSQL documentation or upgrade guides to perform the upgrade. Install the new version, migrate the data, and configure the updated database by restoring the backup you created earlier.

6. Connect your DHIS2 instance: Once the database is upgraded, connect your DHIS2 instance to the new database.

7. Test and validate: Thoroughly test the functionality and performance of your applications against the upgraded database. Validate that all critical operations are functioning as expected.

8. You can easily create the btree\_gin and pg\_trgm extensions by executing the following SQL commands:  
`CREATE EXTENSION IF NOT EXISTS btree_gin;`  
`CREATE EXTENSION IF NOT EXISTS pg_trgm;`

These steps should help guide you through the upgrade process. Make sure to consult the official PostgreSQL documentation and any relevant upgrade guides specific to your environment for detailed instructions and best practices.

**To manually upgrade your dhis2 instance, you can follow these steps:**

1. Access the LXD container by executing the following command:

2. Stop Tomcat:

3. Remove Java 8 and install Java 11:

4. Delete the current dhis2 app and deploy the new one. You can use the `dhis2-deploy-war` script for this:

5. Start tomcat  
`systemctl start tomcat8/9`

These steps will help you manually upgrade your dhis2 instance to the latest version.

---

<div class="post-metadata">

**Author:** ![MohinderS](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mohinders/32/37112_2.png) [@MohinderS](https://community.dhis2.org/u/MohinderS)\
**Post date:** [9 August 2023 07:44 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/10 "2023-08-09T07:44:36Z")

</div>

Once again a big thanks for your response. 👍

---

<div class="post-metadata">

**Author:** ![fernandoshake](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@fernandoshake](https://community.dhis2.org/u/fernandoshake)\
**Post date:** [7 January 2025 13:51 UTC](https://community.dhis2.org/t/manually-update-dhis2-database-and-java-on-lxc/54253/11 "2025-01-07T13:51:23Z")

</div>

Hi @tkipkurgat,

I’m looking for opinions on which items should be on a DHIS 2 Server Administration handover checklist. I will be taking over the job as DHIS 2 System Administrator and I am about to do a course on DHIS 2 Server Administration to gain skills.

I have experience in DHIS 2 System Administration, but I have no experience in DHIS 2 Server Administration.

I would be happy if you could share an example of a server handover document.

Looking forward

Thanks
