
When managing business operations with Dolibarr ERP & CRM, data loss or accidental deletion can occur, whether due to human error, misconfiguration, or system issues. One of the most common problems users face is losing access to an invoice or customer record. This article explores in depth how to recover a lost invoice or customer in Dolibarr, covering preventative measures, step-by-step recovery options, database exploration, and best practices for avoiding future issues.
Understanding How Dolibarr Stores Data
Before diving into the recovery process, it's essential to understand how Dolibarr manages data. Dolibarr is an open-source ERP and CRM platform that relies on a relational database, typically MySQL or MariaDB. Each module, including invoices and customer management, corresponds to a specific set of database tables. For example:
-
Invoices are stored in tables like
llx_facture
andllx_facturedet
. -
Customer (third-party) information is stored in
llx_societe
.
Knowing this structure is crucial when exploring backups or the database directly. Each record has a unique identifier, and many are linked through foreign keys, which ensures data consistency across the platform.
Common Scenarios That Lead to Data Loss
Understanding how data might be lost helps in choosing the best recovery strategy. Common causes include:
-
Accidental deletion: A user might delete a customer or invoice by mistake.
-
Migration issues: Improper data migration or updates can cause record mismatches.
-
Corruption: Server crashes or power failures may result in corrupted tables.
-
Filtering errors: Sometimes data appears "missing" due to misapplied filters in the Dolibarr interface.
Step-by-Step Recovery of a Lost Invoice
Step 1: Double-check the Interface The first step is ensuring the invoice isn’t simply hidden due to a filter. Navigate to:
Commercial > Customers Invoices
Review all applied filters: date ranges, customer names, statuses, etc. Clear all filters to view the full list. Sometimes invoices aren’t deleted but simply excluded from the current view.
Step 2: Use the Global Search Feature Dolibarr has a robust global search bar. Try searching for part of the invoice number, customer name, or amount. This search checks multiple modules and might uncover hidden or misfiled data.
Step 3: Check User Permissions If the invoice was created by another user, you may not have the rights to view it. Check user permissions under:
Home > Users & Groups > Permissions
Make sure the user profile has access to view, edit, or restore invoices.
Step 4: Review the Audit Log If logging is enabled, you can consult the audit log to trace actions. Go to:
Home > Tools > Logs
Look for entries like "DELETE FROM llx_facture" to see if the invoice was removed and when. This can help you pinpoint the loss and possibly identify the user responsible.
Step 5: Restore from Backup If the invoice is truly deleted, restoring from a database backup may be the only option. Here’s how to do it:
-
Identify the backup file created before the deletion.
-
Use phpMyAdmin or a terminal to extract only the needed records.
-
Import the invoice record back into
llx_facture
and associated lines intollx_facturedet
. -
Be cautious to avoid duplicating IDs or breaking relationships with other tables like
llx_societe
orllx_payment
.
Database Restoration Example (Advanced) Assuming you’ve got a backup file (e.g., backup.sql
), run the following commands:
-- Only extract the specific invoice by ID
SELECT * FROM llx_facture WHERE rowid = 1234;
SELECT * FROM llx_facturedet WHERE fk_facture = 1234;
Then manually insert them into the live database using INSERT queries. Always back up your current database before performing such actions.
Recovering a Lost Customer (Third-Party)
Step 1: Filter and Search Go to:
Third Parties > List
Clear all filters and check the alphabetical list. Use the search bar to try partial names, emails, or VAT numbers.
Step 2: Check Archived Records Sometimes customers are archived or set to inactive rather than deleted. Look for a status column and filter by inactive or archived statuses.
Step 3: Audit Logs and Permissions As with invoices, use the log system to verify any deletion and review user permissions to ensure visibility.
Step 4: Backup Restoration If the customer was truly deleted, retrieve the row from llx_societe
using a backup:
SELECT * FROM llx_societe WHERE rowid = 5678;
Manually reinsert this data, taking care with linked tables like llx_socpeople
, llx_commande
, and llx_facture
.
Prevention: Backups and Data Protection Strategies
Prevention is always better than cure. Here are best practices to avoid data loss:
-
Regular Backups: Automate daily database backups. Use tools like
mysqldump
or third-party plugins for scheduled backups. -
Role-Based Access Control: Limit deletion rights to admin users only. Carefully define roles under the Users & Groups module.
-
Enable Audit Logs: Ensure logging is active to trace changes. This helps with accountability and recovery.
-
Use Dolibarr Modules for Trash or Archive: Some modules offer a trash or recycle bin. Consider installing these for soft deletions.
-
Train Staff: Provide internal training on how to use filters, search functions, and permissions to reduce human error.
Using Third-Party Tools
Several external tools can assist with data recovery:
-
phpMyAdmin: For browsing and restoring database tables manually.
-
MySQL Workbench: Offers visual queries and data exports.
-
Dolibarr Modules from DoliStore: Some modules enhance recovery options or add trash bin features.
Custom Development Solutions
For companies frequently dealing with accidental deletions, a custom module might be a worthwhile investment. A developer can create a plugin that logs deletions or provides a temporary storage (like a trash system), allowing for easy recovery. Since Dolibarr is open-source, it's highly customizable for such needs.
Conclusion: Stay Vigilant and Prepared
Recovering lost invoices or customer data in Dolibarr isn’t always straightforward, but it’s entirely feasible with the right approach. Start with simple checks in the UI and move to deeper methods like database recovery only when necessary. The key to long-term stability is prevention: backups, access control, and user training. With these in place, you can maintain confidence in your Dolibarr installation and reduce the stress of accidental data loss.
If you’re managing sensitive or high-volume data in Dolibarr, make recovery and backup procedures a routine part of your business operations. Doing so ensures that even when something goes wrong, you're only a few steps away from setting it right.