The root of the problem
Failures in Odoo's automatic backups and Filestore directory overflow are common issues faced by system administrators. These problems are usually related to the Odoo system user lacking write permissions on the default backup directory or the accumulation of orphaned attachment files in the Filestore folder.
Insufficient write permissions
When the Odoo system user doesn't have the proper permissions to write to the backup directory, automatic backups can fail. This can happen due to changes in server configuration or following a system update.
Accumulation of orphaned attachment files
The Filestore folder stores all attachments associated with Odoo records. However, if these records are deleted without the corresponding attachments being removed, orphaned files can pile up, taking up unnecessary space on the hard drive.
Step by step: Solving backup and Filestore issues
Fix permissions on Odoo’s data folders
To make sure the Odoo system user has the proper permissions, you can use the
chown and
chmod commands on Linux. Follow these steps:
- Open a terminal on your server.
- Run the following command to change ownership of the backup directory:
sudo chown -R odoo:odoo /ruta/al/directorio_de_respaldos - Make sure the odoo user has write permissions:
sudo chmod -R 755 /ruta/al/directorio_de_respaldos - Verify that the permissions have been applied correctly.
Set up an external automated backup script
To prevent future issues, you can set up an automated backup script that combines exporting the PostgreSQL database with packaging the Filestore folder:
- Create a new script on your server, for example,
/ruta/al/script/backup_odoo.sh. - Add the following content to the script:
#!/bin/bash
# Exportar la base de datos
pg_dump -U odoo -F c -b -f /ruta/al/backup/odoo_db_$(date +%F).backup nombre_de_la_base_de_datos
# Empaquetar la carpeta Filestore
tar -czvf /ruta/al/backup/odoo_filestore_$(date +%F).tar.gz /ruta/al/filestore
- Make the script executable:
sudo chmod +x /ruta/al/script/backup_odoo.sh</li - Schedule the script to run automatically using
cron. Edit the crontab file:
crontab -e - Add the following line to run the script daily at 2 AM:
0 2 * * * /ruta/al/script/backup_odoo.sh
Clean up orphaned files in Filestore
To remove orphaned attachment files in the Filestore folder, you can use a tool such as
Auto Clean Attachments in Odoo, or perform a manual cleanup by following these steps:
- Identify orphaned files by comparing the files in Filestore against the records in the database.
- Delete files that don't have a corresponding record.
- Optimize disk space with tools like
fstrim or du to make sure the space has been freed up correctly.
Frequently Asked Questions (FAQs)
How do I know if my Filestore directory is overflowing?
You can use the
du -sh /ruta/al/filestore command to check the size of the Filestore directory. If the size is excessive and coincides with low database space usage, there are likely orphaned files.
Is it safe to manually delete files in Filestore?
Yes, as long as you make sure the deleted files have no associated records in the database. It's advisable to make a backup before proceeding with the cleanup.
What should I do if the backup script fails?
Check the permissions on the backup directory and make sure the odoo user has access. Also review the script's error log to identify possible issues.