3 min read

How to backup Directus

Updating Directus can sometimes break your project, especially if you have custom extensions. Use this article to backup your project and keep your data safe.

Updating Directus is a simple process and can be completed in just a few commands but sometimes changes can happen that will break your project, especially if you have custom extensions. This article will cover how you can backup your Directus project so you can restore after a failed update. This will require command-line access to your Directus project folder and storage locations.

To backup Directus, make a copy of your project files, .env file and perform a data dump of your database.

Backing-up a Project

It is important to make a backup of your project in case everything goes very badly. Some updates will make changes to your database which will making rolling back to previous versions impossible.

  1. Make a copy of the files within each storage adapter, and store them in a safe place. This can be a zip/tar file somewhere on the same server so you can easily extract them again if needed. If space is an issue, the backup can be stored elsewhere once you are happy the update has succeeded.
  2. Make a copy of the Env file (/project_folder/.env), and store it in a safe place. This contains all your configurations.
  3. Create a database dump (a sql backup of your database)

MySQL Backup

From the terminal, run this command and replace the [database_name] with the Directus database.

// MySQL
mysqldump -u [user name] –p [password] [database_name] > /path/dumpfilename.sql

To restore the database, make sure to drop the existing database and create and empty one. Run the following in the mysql console.

> DROP DATABASE database_name;
> CREATE DATABASE database_name;
> GRANT ALL PRIVILEGES TO database_name.* FOR username IDENTIFIED BY 'password';

Quit the mysql console back to shell. Then restore the database from the sql dump.

mysql -u [user] -p [database_name] < /path/dumpfilename.sql

PostgreSQL Backup

From the terminal, run this command and replace the [database_name] with the Directus database.

pg_dump [database_name] > /path/dumpfilename.sql

To Restore the backup, you need to drop the database first.

psql template1 -c 'drop database [database_name];'

Now recreate the database.

psql template1 -c 'create database [database_name] with owner [your_user_name];

Lastly, restore the SQL dump to the empty database.

psql [database_name] < /path/dumpfilename.sql

MSSQL Backup

Use the SQL Server Management Studio (SSMS) software to make a backup. Right-click on the database, then go to Tasks and click Backup. Follow the prompts to complete the process.

Now that you have a backup of your project, you can update to the latest version.

How to Update Directus?
It’s important to keep Directus up to date. Each new version fixes bugs or issues that have been discovered since the last version and sometimes includes new exciting features.


Now you know how you backup Directus and update it to the latest version. It's worth storing your backups offline for a few weeks to ensure everything is working as expected.

To stay informed of new releases, subscribe to this website below.

By continuing to use our website, you consent to use essential cookies. We also use optional tracking cookies which help us gather statistics to improve our services. Do you consent to these cookies?

I Consent Do not track