Table of Contents
-
Introduction
-
Why Backups Matter: The Real Risks
-
Understanding Dolibarr Architecture
-
What You Need to Backup
-
Backup Types: Manual vs Automated
-
Step 1: Backup the Database (MySQL/MariaDB)
-
Step 2: Backup the Document Directory
-
Step 3: Backup the Configuration File (
conf.php
) -
Step 4: Scheduling Automated Backups
-
Step 5: Secure Backup Storage Practices
-
How to Restore a Dolibarr Instance
-
Testing Your Backup & Restore Process
-
Common Mistakes to Avoid
-
Final Thoughts
1. Introduction
Dolibarr ERP & CRM is a modular, open-source platform used by thousands of small to medium-sized enterprises across the globe. It handles everything from invoicing and CRM to accounting, HR, and inventory. Because Dolibarr often becomes the core system of record for many businesses, ensuring that your instance is properly backed up and recoverable is not optional—it’s essential.
In this article, we’ll walk through a detailed, step-by-step guide on how to securely back up and restore Dolibarr, using best practices that reduce the risk of data loss, corruption, or misconfiguration. Whether you’re managing your ERP in a shared hosting environment, VPS, cloud server, or on-premise setup, this guide applies to all Dolibarr deployments.
2. Why Backups Matter: The Real Risks
While Dolibarr is reliable, many external factors can disrupt your instance:
-
Server crashes or hard disk failure
-
Human error: accidental deletion of records or files
-
Software upgrades gone wrong
-
Security breaches or ransomware attacks
-
Corrupted database from improper shutdowns
-
Hosting provider outages
Without a working backup and a clear restoration plan, these events can lead to total loss of business-critical data, massive downtime, and even legal issues.
Backups aren’t just a precaution—they are an integral part of your business continuity and disaster recovery strategy.
3. Understanding Dolibarr Architecture
To properly back up and restore Dolibarr, you need to understand what makes up a complete Dolibarr installation.
A standard Dolibarr instance consists of:
-
Application files: PHP scripts in
/htdocs/
(usually untouched unless customized) -
Configuration file:
conf.php
in/htdocs/conf/
(contains DB connection info) -
Document directory:
/documents/
stores uploaded files (PDFs, logos, attachments) -
Database: MySQL or MariaDB database where all records are stored
Therefore, a complete backup includes:
-
The database
-
The documents directory
-
The configuration file
-
Optionally, any custom modules or templates in
/custom/
or/theme/
4. What You Need to Backup
Here’s what you need to save regularly:
Component | Location | Why It Matters |
---|---|---|
Database | MySQL/MariaDB | Contains all business data, users, invoices, stock, etc. |
Document Files | /dolibarr/documents/ |
Contains uploaded files, invoice PDFs, images |
Configuration File | /dolibarr/htdocs/conf/conf.php |
Needed to reconnect Dolibarr to its database |
Custom Modules & Themes |
/dolibarr/htdocs/custom/ and /theme/
|
Preserves custom functionality |
Logs (optional) | /dolibarr/logs/ |
Helps debug problems during restore |
A partial backup (e.g., database only) can be dangerous. Always ensure your backup is complete and consistent.
5. Backup Types: Manual vs Automated
You can back up Dolibarr either:
-
Manually using command-line tools or a hosting control panel
-
Automatically using scripts or tools like
cron
,rsync
, or third-party backup services
For production environments, a hybrid approach is recommended:
-
Daily automated backups stored securely
-
Weekly manual checks to verify integrity
-
Monthly offsite backups (to external storage or cloud)
Now, let’s walk through the backup steps in detail.
6. Step 1: Backup the Database (MySQL/MariaDB)
The database is the heart of your Dolibarr system. It holds all structured data—clients, invoices, users, stock, accounting entries, and more.
6.1 Backup with mysqldump
(recommended method)
Run this command via terminal or SSH:
Replace your_db_user
and your_db_name
accordingly.
You’ll be prompted for the database password. This creates a .sql
file that can be used later to restore your data.
6.2 Backup with phpMyAdmin (GUI method)
If you're using a web hosting panel:
-
Login to phpMyAdmin
-
Select the Dolibarr database
-
Click Export > Custom
-
Select all tables, use SQL format
-
Click Go to download the backup file
Best Practices:
-
Always include the
DROP TABLE IF EXISTS
option in exports -
Use gzip to compress backups:
gzip dolibarr_backup.sql
-
Use a timestamped filename to avoid confusion
-
Store the file outside your public web root
7. Step 2: Backup the Document Directory
Dolibarr stores uploaded documents in:
This directory contains:
-
Generated invoice PDFs
-
Uploaded logos, contracts, employee documents
-
Signed proposals and scanned documents
Command-line Method:
With rsync
:
Best Practices:
-
Maintain folder structure
-
Sync this folder as often as you back up the database
-
Consider encrypting archive files for sensitive content
8. Step 3: Backup the Configuration File (conf.php
)
Dolibarr’s configuration file contains your database credentials and system settings.
Location:
Use the following command:
Make sure it is:
-
Stored securely (not accessible from the web)
-
Backed up regularly, especially after upgrades or reconfigurations
-
Protected with appropriate permissions (
chmod 640
)
9. Step 4: Scheduling Automated Backups
Manual backups are useful for testing and emergency snapshots, but automated backups are what protect your data consistently. Here's how to schedule them using cron
and simple shell scripts.
9.1 Create a Shell Script for Full Backup
Example: /usr/local/bin/backup_dolibarr.sh
Make the script executable:
9.2 Add a Cron Job
Run daily at 2 AM:
This ensures your Dolibarr instance is backed up automatically and silently, reducing human error.
10. Step 5: Secure Backup Storage Practices
Backing up is only half the job—storing backups securely is equally important.
10.1 Use Encrypted Storage
-
Encrypt backup files using
gpg
: -
Store passphrases securely using a password manager or secure vault
10.2 Store Backups Offsite
Always follow the 3-2-1 rule:
-
3 copies of your data
-
On 2 different storage types
-
1 copy offsite (e.g., cloud)
Use services like:
-
AWS S3 (with lifecycle policies)
-
Backblaze B2
-
Google Drive via
rclone
-
External encrypted hard drives
10.3 Set File Permissions and Ownership
Restrict access:
Don’t store backups in web-accessible directories.
11. How to Restore a Dolibarr Instance
If your system crashes, you’ll need to fully restore your Dolibarr environment from backup.
11.1 Restore the Database
-
Create a new MySQL database:
-
Import your
.sql
backup:
Ensure the user has proper privileges:
11.2 Restore the Document Directory
Extract your archive:
Ensure ownership and permissions:
11.3 Restore the Configuration File
Copy your backed-up conf.php
:
Check database credentials and file permissions:
11.4 Restart Services and Test
After restoring:
-
Restart Apache/Nginx and MySQL
-
Log in to Dolibarr
-
Check that invoices, clients, and documents are accessible
-
Verify PDF generation and module functionality
12. Testing Your Backup & Restore Process
Backups are useless if you never test them. Schedule regular test restores in a staging or local environment.
Testing Checklist:
-
Restore database and login
-
Validate recent records and documents
-
Check PDFs and reports
-
Verify cron and API endpoints
-
Confirm version compatibility after restores across versions
Simulate worst-case scenarios (e.g., server crash) to validate your disaster recovery readiness.
13. Common Mistakes to Avoid
Avoid these common pitfalls:
Mistake | Impact |
---|---|
Backing up database only | Loss of document attachments and config |
Storing backups in /htdocs/
|
Exposes sensitive files to the internet |
Skipping encryption | Risk of data leaks in the event of theft |
Forgetting to test backups | You won’t know they’re broken until it’s too late |
Not automating backups | Increased human error and gaps in protection |
Not versioning custom modules | Lost changes after upgrade or restore |
Overwriting live data during test restores | Permanent data loss |
Always treat backups as part of your production system, not an afterthought.
14. Final Thoughts
A solid backup and restore strategy is the cornerstone of any Dolibarr deployment—regardless of your company size or industry. Whether you’re running a small accounting firm, an e-commerce business, or a logistics company, your ERP system is too critical to be left vulnerable to data loss.
By following the steps outlined in this article, you’ll achieve:
-
Full control over your data
-
Faster recovery after failures or upgrades
-
Peace of mind knowing your system is safe
-
Regulatory compliance with data retention policies
Remember: it’s not a question of if something will go wrong, but when. With automated, secure, and regularly tested backups in place, your Dolibarr instance will be resilient and dependable—just as your business needs it to be.