How to Update InvoiceNinja v.5 on VM/bare metal


I’ve been successfully using a self-hosted version of InvoiceNinja for my own business for about one year now and it’s been brilliant. The one caveat to that has been updates. Until now, every time I attempted to update either via web UI or on the command line, the process would fail horribly with 500 errors or 503 errors and several other web errors. After extensive searching and experimenting, I finally have the process set and it has successfully worked multiple times now.

Similarly to how I found this guide helpful, I thought I might share this and hopefully help a few others as well. This process only takes a few minutes (depending on the size of installation).

Base assumptions. All steps below assume you have sudo access via SSH. My installation is in production and is directly installed inside a VM (i.e. NO DOCKER) with nothing else installed, using Ubuntu 22.04, nginx, and mariadb; using the file method of installation. These directions should work for CentOS, Fedora (I previously had it installed in Fedora), etc.; just use your relevant commands to do so. I have my installation located in /var/www/invoiceninja; however, you should use the path to wherever you have your instance installed, as locations may vary depending on which directions you followed and if you are using Apache2 or Nginx and other factors.

InvoiceNinja VM Update

Backup Database

  • sudo mysqldump -u root ninjadb > ninjadb.(date).sql
    • replace (date) with the current date. Ex: ninjadb.19.02.2024.sql
    • make sure you use the correct name for your active database, mine is ninjadb, yours may be different. The backup will fail without the correct db name.
    • Over time, you may wish to delete or move older versions of the back up and only keep the most recent one or two, as they can be large and take up lots of valuable space on the server.

Backup Web Files

  • sudo tar -cpzvf invoiceninja.(date).tar.gz /path/to/invoiceninja/
    • replace (date) with the current date. Ex: invoiceninja.19.02.2024.tar.gz
    • Similarly to above, over time, you may wish to delete or move older versions of the back up and only keep the most recent one or two, as they can be large and take up lots of valuable space on the server.

Download & Install Update

  • cd /path/to/invoiceninja
  • sudo wget
    • (select and copy the link for the tarball of the latest release from Github - that is the latest as of writing this guide. You could also download the react only version instead of the full version with Flutter.)
  • sudo tar -xf invoiceninja.tar
  • delete zip file: sudo rm /path/to/invoiceninja/invoiceninja.tar

Update ownership

  • sudo chown www-data:www-data /path/to/invoiceninja -R

Install Update

  • sudo -u www-data composer install


  • sudo -u www-data php artisan migrate
    • Application in production. Are you sure you want to run this command?
      • Yes


  • sudo -u www-data php artisan optimize

FINISHED! Login to your updated system.

I hope this helps someone as I had not previously found any clear documentation on how to manually update my installation.

Edits: Various clarifications on assumptions.

Edit 2: Updated to reflect that as of 5.9.2, the ZIP file is no longer available and only tarballs are used.


This is great, thanks for sharing!

1 Like

I’ve updated the instructions due to the change from zip files to tarballs.


I us the backup sql using a daily cron job and the date +%A as well but I use:


#keep a weeks worth of invoice backups 
/usr/bin/mysqldump --add-drop-table --user=root --password=password ninjadb  >  $FILELOCATION/ninja-$(date +%A).sql

This gives you a weeks worth of backup and it automatically overwrites the older backups like this:

-rw-r--r-- 1 root   root      242225 Jun 28 23:15 ninja-Friday.sql
-rw-r--r-- 1 root   root      242225 Jul  1 05:15 ninja-Monday.sql
-rw-r--r-- 1 root   root      242225 Jun 29 23:15 ninja-Saturday.sql
-rw-r--r-- 1 root   root      242225 Jun 30 23:15 ninja-Sunday.sql
-rw-r--r-- 1 root   root      242225 Jun 27 23:15 ninja-Thursday.sql
-rw-r--r-- 1 root   root      242225 Jun 25 23:15 ninja-Tuesday.sql
-rw-r--r-- 1 root   root      242225 Jun 26 23:15 ninja-Wednesday.sql

1 Like

Nice. Thanks for sharing. Great idea.