Backup and Restoration of Dolibarr Data: A Practical Guide
   03/12/2025 00:00:00     Dolibarr    0 Comments
Backup and Restoration of Dolibarr Data: A Practical Guide

Dolibarr is an open-source ERP and CRM that enables businesses to manage their commercial, accounting, and logistics activities. Like any enterprise management system, data protection is essential to prevent losses due to system failures, cyberattacks, or human errors.

Implementing an effective backup and restoration plan ensures the security of your data and allows for a quick recovery in case of incidents. In this article, we will explore best practices for backing up and restoring Dolibarr data, detailing various methods, tools, and configurations you can use.


1. Why Back Up Dolibarr Data?

Losing data can have disastrous consequences for a business:

Loss of critical information (invoices, quotes, accounting, customer contacts).
Prolonged downtime, affecting productivity.
Legal compliance issues, especially for accounting and personal data management.
Risk of cyberattacks (ransomware, viruses, etc.).

A well-defined backup strategy helps protect your business against these risks and ensures business continuity in case of failure.


2. Understanding the Data to Back Up

Dolibarr stores two main types of data, both of which should be included in your backup strategy:

1️⃣ The database (MySQL/MariaDB) – Stores all critical information: customers, quotes, invoices, orders, products, users, etc.
2️⃣ Dolibarr files – Includes attached documents, invoices in PDF format, images, installed modules, and software configurations.

Backing up both the database and Dolibarr files is essential to ensure a complete system restoration.


3. Backup Methods for Dolibarr

There are several ways to back up Dolibarr, depending on your infrastructure and security needs.

3.1 Manual Backup via MySQL and FTP

???? Steps to back up the database:
1️⃣ Log into your server via SSH or access phpMyAdmin.
2️⃣ Run the following command to export your MySQL/MariaDB database:

bash
mysqldump -u root -p dolibarr_db > dolibarr_backup.sql

3️⃣ Download the backup file to your local computer or a secure external storage.

???? Steps to back up Dolibarr files:
1️⃣ Access your server via FTP (FileZilla) or SSH.
2️⃣ Copy the important directories:

  • /htdocs/ (source code and modules)
  • /documents/ (invoices, images, attachments)
    3️⃣ Store these files on an external hard drive or a secure cloud storage.

3.2 Automatic Backup Using a CRON Script

If you want to automate the backup process, you can create a CRON script that will back up the data at regular intervals.

???? Example of an automatic backup script:
1️⃣ Create a backup script file:

bash
#!/bin/bash TIMESTAMP=$(date +"%F") BACKUP_DIR="/backup" MYSQL_USER="root" MYSQL_PASSWORD="password" DATABASE_NAME="dolibarr_db" mkdir -p $BACKUP_DIR/$TIMESTAMP mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $DATABASE_NAME > $BACKUP_DIR/$TIMESTAMP/dolibarr_db.sql tar -czf $BACKUP_DIR/$TIMESTAMP/dolibarr_files.tar.gz /var/www/dolibarr/htdocs

2️⃣ Add this script to CRON to run it daily:

bash
crontab -e

Add this line:

bash
0 2 * * * /path/to/backup_script.sh

➜ This will create a backup every day at 2 AM.


3.3 Backup to a Remote Server or Cloud Storage

To enhance security, it is recommended to store a copy of the backups on a remote server or secure cloud storage (Google Drive, AWS S3, Nextcloud).

???? Send a backup to a remote server using SCP:

bash
scp /backup/dolibarr_db.sql user@remote_server:/remote_backup_directory/

???? Use Rclone to back up Dolibarr to Google Drive:

bash
rclone copy /backup remote:GoogleDriveBackup/Dolibarr/

4. Restoring Dolibarr Data

If you lose your data or need to reinstall Dolibarr, here’s how to restore your backups.

4.1 Restoring the Database

???? Steps to restore MySQL/MariaDB:
1️⃣ Copy the backup file to your server.
2️⃣ Run the following command to restore the database:

bash
mysql -u root -p dolibarr_db < dolibarr_backup.sql

3️⃣ Check that Dolibarr functions properly after the restoration.


4.2 Restoring Dolibarr Files

???? Steps to restore files:
1️⃣ Copy your backup files to the Dolibarr directory:

bash
tar -xzf dolibarr_files.tar.gz -C /var/www/dolibarr/htdocs

2️⃣ Check file permissions and ownership:

bash
chown -R www-data:www-data /var/www/dolibarr/ chmod -R 755 /var/www/dolibarr/

5. Best Practices for Reliable Backups

Automate backups (at least once a day for databases, once a week for files).
Store multiple versions of backups to prevent corruption of recent files.
Use external secure storage to avoid data loss due to server failures.
Regularly test your restorations to ensure your backups are functional.
Encrypt sensitive backups before sending them to a remote server.


Conclusion

An effective backup and restoration strategy is essential to protect Dolibarr data from accidental loss, cyberattacks, and human errors. By following these best practices, you ensure business continuity and a quick recovery in case of an incident.

???? Summary of key steps:
1️⃣ Regularly back up the Dolibarr database and files.
2️⃣ Implement an automatic backup system.
3️⃣ Store backups securely on a remote server or cloud.
4️⃣ Regularly test the restoration process to ensure reliability.

Comments

Log in or register to post comments