How to Back Up and Restore Dolibarr Safely
   04/11/2025 00:00:00     Dolibarr , Wiki Dolibarr    0 Comments
How to Back Up and Restore Dolibarr Safely

Running an ERP/CRM like Dolibarr involves managing critical business data: customer information, invoices, inventory, HR records, and much more. Loss or corruption of this data could be catastrophic. That's why having a robust backup and restore strategy is not just important — it's absolutely essential.

In this guide, we'll dive deep into everything you need to know to back up and restore your Dolibarr instance safely, covering manual methods, automated strategies, best practices, common mistakes, and advanced tips.

Why Backing Up Dolibarr Is Critical

Whether you're running a small business or a larger enterprise, your Dolibarr system is the backbone of your operations. Consider these real-world risks:

  • Hardware Failures: Disk crashes and server failures can happen at any time.

  • Human Errors: Accidental deletion or overwriting of important records.

  • Cyberattacks: Ransomware and hacking attempts are a constant threat.

  • Software Issues: Updates or plugin installations can sometimes corrupt data.

  • Natural Disasters: Fire, flood, or power failures can destroy physical infrastructure.

A reliable backup allows you to recover quickly from these incidents with minimal data loss.

Understanding Dolibarr's Structure

Before backing up Dolibarr, it’s essential to understand its two main components:

  1. Database: All core data (clients, invoices, projects, etc.) are stored in a MySQL or MariaDB database.

  2. Files: Uploaded files, logos, PDF documents, and custom modules are stored in Dolibarr's /documents/ directory and possibly other custom paths.

You must back up both components to perform a complete recovery.

Preparing for Backup: Key Requirements

  • Access to Server: SSH access for Linux servers or Control Panel (e.g., cPanel) for shared hosting.

  • Database Credentials: Username, password, database name.

  • File System Access: Access to the Dolibarr installation directory.

  • Backup Storage: Secure, remote storage like external hard drives, cloud storage (AWS S3, Dropbox, etc.).

  • Scheduling Tools: For automated backups (cron jobs, backup plugins, etc.).

Manual Backup of Dolibarr

Let's start with the manual process, useful for small setups or ad-hoc backups.

Step 1: Back Up the Database

Use mysqldump (for Linux) or phpMyAdmin (for web interfaces).

Using mysqldump (Command Line):

mysqldump -u your_db_user -p your_db_name > dolibarr_backup.sql

Using phpMyAdmin:

  • Login to phpMyAdmin.

  • Select your Dolibarr database.

  • Click "Export."

  • Choose "Quick" and "SQL" format.

  • Download the file.

Step 2: Back Up the Dolibarr Files

  • Connect to the server using FTP/SFTP or SSH.

  • Download the entire Dolibarr directory (e.g., /var/www/html/dolibarr/).

  • Pay special attention to the /documents/ folder and /conf.php configuration file.

Manual Restoration of Dolibarr

Step 1: Restore the Database

Using Command Line:

mysql -u your_db_user -p your_db_name < dolibarr_backup.sql

Using phpMyAdmin:

  • Create a new database.

  • Import the .sql backup file.

Step 2: Restore the Dolibarr Files

  • Upload the Dolibarr files back to the server.

  • Ensure correct permissions (e.g., 755 for directories, 644 for files).

  • Update the /conf/conf.php file if database credentials or paths have changed.

Automating the Backup Process

Manually backing up is fine occasionally, but for production systems, automation is key.

Database Backup Automation

Use cron jobs to create daily database dumps.

Example crontab entry:

0 2 * * * /usr/bin/mysqldump -u your_db_user -pyour_password your_db_name > /path/to/backups/dolibarr_db_$(date +\%F).sql

This will back up the database every night at 2 AM.

File Backup Automation

Use rsync or scheduled FTP transfers.

Example using rsync:

rsync -avz /var/www/html/dolibarr/ /path/to/backups/dolibarr_files/

Schedule this via cron as well.

Using Backup Tools

If you’re using cPanel, Plesk, or a cloud server, they often have automated backup features. Configure them to:

  • Include both database and files.

  • Retain multiple backup versions.

  • Encrypt backups.

Best Practices for Dolibarr Backup and Restore

1. Follow the 3-2-1 Rule

  • 3 copies of your data.

  • 2 different storage types (local and remote).

  • 1 copy offsite (cloud storage or external location).

2. Verify Backups Regularly

A backup that doesn’t work is worse than no backup. Test restoring your backup at least monthly.

3. Encrypt Sensitive Data

Use encryption for backups, especially if stored offsite.

4. Maintain Versioning

Keep several historical copies of your backups. This way, you can roll back even if an issue goes unnoticed for several days.

5. Automate and Monitor

Set up email alerts or monitoring dashboards to confirm backups were completed successfully.

Common Backup Mistakes to Avoid

  • Not backing up both database and files.

  • Saving backups on the same server (which can be compromised).

  • No encryption for backups.

  • Infrequent backups (daily minimum for production environments).

  • Not testing restores.

  • Ignoring database schema changes after upgrades.

Advanced Backup Strategies

1. Incremental Backups

Instead of full backups every time, back up only changes after the initial full backup. Saves space and time.

2. Snapshot-Based Backups

Use tools like LVM snapshots (Linux) or VM snapshots (for virtualized environments) for near-instant backups.

3. Remote Replication

Set up real-time replication to another server or cloud database (e.g., using MySQL replication).

4. Backup Dolibarr with Docker

If you run Dolibarr in a Docker container, back up:

  • Volumes (for uploaded files)

  • Database container exports

  • Docker Compose files

Example database dump inside Docker:

docker exec your_mysql_container sh -c 'exec mysqldump -u your_user -p"your_password" your_db_name' > backup.sql

Real-World Example: Setting Up Complete Backup System

Imagine a company using Dolibarr for their sales and inventory management. Their setup includes:

  • Dolibarr installed on a VPS.

  • MySQL database.

  • Regular updates and plugin installations.

They implemented the following:

  1. Nightly cron job to back up database and files.

  2. Weekly upload of encrypted backups to AWS S3.

  3. Monthly restore tests on a staging server.

  4. Email notifications for backup success/failure.

Result: They minimized downtime when their main server failed, restoring their operations in under an hour.

Conclusion

Backing up and restoring your Dolibarr system isn’t optional — it’s critical to your business continuity. Fortunately, Dolibarr’s architecture makes it relatively straightforward to set up a solid backup strategy.

Whether you opt for manual methods or implement a full-fledged automated backup system, the key is consistency, security, and regular testing.

Start building or improving your backup strategy today — because in the world of data management, it’s not "if" something goes wrong, but "when."

Comments

Log in or register to post comments