Step-by-Step Guide and Tips
Configure Odoo filestore plays a critical role in maintaining your Odoo system. First, we set up Odoo file storage by adjusting the data_dir and managing filestore folders. Moreover, we handle attachments outside the database to boost performance and simplify backups. Therefore, we avoid data loss and speed up recovery. Finally, this tutorial will guide you to Configure Odoo filestore step by step, share best practices, backup plans, and troubleshooting tips. For more details, visit the Odoo Documentation.
Why Configure Odoo filestore Matters
First, you isolate heavy binary data from your PostgreSQL database. Next, you cut down on database bloat. Moreover, you speed up database dumps and restores. Also, you support clean separation of files and tables. Therefore, you streamline daily operations and backups.
- Performance boost: Odoo stores images, PDFs, and other attachments in the filestore.
- Backup simplicity: You back up one folder instead of every large BLOB column.
- Scalability: You add storage without impacting database size.
- Reliability: You avoid timeouts on large database exports.
Consequently, you gain a faster, more reliable Odoo platform. In addition, you reduce I/O pressure on PostgreSQL. Finally, you safeguard your critical business files.
Understanding Odoo file storage mechanism
Odoo file storage architecture
First, Odoo records attachment metadata (filename, mimetype, checksum) in the table ir_attachment. Next, it writes the actual binary data to a folder named filestore inside your data_dir. Moreover, it hashes each file into a uniquely named subfolder to avoid collisions.
<data_dir>/
└── <database_name>/
└── filestore/
├── ab/
│ └── abcdef1234567890...
└── cd/
└── cdefabcdef1234...
How Odoo maps attachments to filestore
First, Odoo computes a SHA256 hash of the file content. Next, it splits the first two characters of that hash as a folder name. Then, it places the file under filestore/<db_name>/<first_two_chars>/<hash>. Finally, Odoo links that path back to the metadata record in PostgreSQL. Consequently, Odoo achieves both performance and integrity.
How to Configure Odoo filestore
Step 1: Create data directory
First, choose a stable path on your server. Next, create the base directory and a subfolder for your database. Then, set proper ownership and permissions.
Linux / macOS
# Create base data directory
sudo mkdir -p /srv/odoo/data
# Create database-specific filestore
sudo mkdir -p /srv/odoo/data/mydb/filestore
# Assign ownership to the Odoo user (e.g., 'odoo')
sudo chown -R odoo:odoo /srv/odoo/data
# Set secure permissions
sudo chmod -R 750 /srv/odoo/data
We run these commands to ensure that Odoo can write new files and that other users cannot tamper with your filestore.
Windows
- Open PowerShell as Administrator.
- Execute:
New-Item -ItemType Directory -Path C:\odoo\data\mydb\filestore
icacls "C:\odoo\data" /grant "ODooUser:(OI)(CI)RX" /inheritance:r
- Replace
ODooUserwith your service account.
We configure Windows permissions to grant only necessary rights.
Step 2: Update odoo.conf
First, open your Odoo configuration file. Next, set the data_dir to your new directory. Then, save and close.
[options]
; ——————————————————————————
; Filestore configuration
; ——————————————————————————
data_dir = /srv/odoo/data
We add data_dir so Odoo knows where to look for the filestore. Otherwise, it uses the default path under the user’s home directory.
Step 3: Adjust file permissions
First, verify that the Odoo user can read and write to the data folder. Next, correct any permission issues:
sudo chown -R odoo:odoo /srv/odoo/data
sudo chmod -R 750 /srv/odoo/data
We enforce secure permissions so that only the Odoo process can modify attachments.
Step 4: Restart Odoo service
First, restart Odoo to apply the new settings. Next, monitor logs to confirm success.
sudo systemctl restart odoo
sudo journalctl -u odoo -f
We watch for messages like:
INFO odoo.service: Filestore located at '/srv/odoo/data/mydb/filestore'
Configure Odoo filestore in Docker
Mount volume in docker-compose.yml
First, open docker-compose.yml. Next, mount the host folder to the container. Then, ensure that data_dir matches.
services:
odoo:
image: odoo:18.0
volumes:
- ./config/odoo.conf:/etc/odoo/odoo.conf:ro
- ./data:/var/lib/odoo/data:rw
ports:
- "8069:8069"
We mount ./data (host) to /var/lib/odoo/data (container).
Update config in Docker
First, set data_dir to /var/lib/odoo/data in your odoo.conf. Next, rebuild or restart:
docker-compose up -d --build odoo
docker logs -f <container_id>
We validate that the container uses the correct filestore path.
Best Practices for Odoo file storage
Filestore backup strategies
First, include the filestore in every backup job. Next, use rsync or similar tools:
# Backup database
pg_dump -Fc odoo_db > /backups/db-$(date +%F).dump
# Backup filestore
rsync -a --delete /srv/odoo/data/mydb/filestore/ /backups/filestore-$(date +%F)/
We recommend daily backups and weekly full snapshots. Moreover, we advise storing backups offsite.
Security best practices
First, restrict filestore access to the Odoo service account. Next, run Odoo behind HTTPS (SSL/TLS). Then, disable directory listing on your web server. Furthermore, scan for malware and check file integrity. Finally, rotate keys and passwords regularly.
Monitor filestore usage
First, monitor disk usage with tools like du or ncdu. Next, alert when usage crosses a threshold:
du -sh /srv/odoo/data/mydb/filestore
We can integrate this into Nagios or Prometheus for proactive monitoring.
Troubleshooting Common Issues in Odoo FileStore
Filestore not found error
First, confirm data_dir in odoo.conf. Next, verify that the path exists. Then, check owner permissions.
ls -ld /srv/odoo/data
We ensure that the Odoo user sees the directory.
Permission denied on filestore
First, inspect file and folder modes. Next, run:
sudo chown -R odoo:odoo /srv/odoo/data
sudo chmod -R 750 /srv/odoo/data
We restore proper permissions and prevent unauthorized access.
Corrupted filestore entries
First, scan for missing files:
psql -d odoo_db -c "SELECT count(*) FROM ir_attachment WHERE store_fname NOT IN (SELECT oid FROM pg_largeobject);"
Next, restore missing files from backup. Then, restart Odoo.
Advanced Filestore Management
Configure Odoo filestore further by following these advanced tips. First, automate cleaning of orphan files to free up space. Next, integrate cloud storage for added redundancy. Then, enable caching to speed up file access. Finally, monitor usage and set alerts for early intervention.
Automate Orphan File Cleanup
First, you scan for files that lack a matching ir_attachment record. Next, you run a simple Python script as a daily cron job to remove those orphans:
import os, hashlib
from odoo import api, SUPERUSER_ID
def clean_orphan_files(env):
attachments = env['ir.attachment'].search([])
hashes = set(a.store_fname for a in attachments)
filestore = os.path.join(env['config'].data_dir, env.cr.dbname, 'filestore')
for root, _, files in os.walk(filestore):
for fname in files:
if fname not in hashes:
os.remove(os.path.join(root, fname))
Then, you schedule it with:
0 2 * * * /usr/bin/odoo shell -c /etc/odoo/odoo.conf -d mydb -e clean_orphan_files
This routine keeps your storage lean and avoids wasted space.
Archive and Compress Old Attachments
First, you identify attachments older than a set threshold (e.g., 12 months). Next, you archive them into a timestamped tarball:
find /srv/odoo/data/mydb/filestore -type f -mtime +365 | \
tar -czvf /backups/old_attachments_$(date +%F).tar.gz -T -
Then, you move the archive to offsite storage or cold storage. Furthermore, you delete the original files after verifying the archive integrity. This workflow keeps your live filestore small yet preserves historical data.
Cloud Storage Integration
Configure Odoo filestore to use S3-compatible services for offsite backup. First, install a community module like odoo-s3-backup. Then, add these settings to odoo.conf:
[options]
s3_endpoint = s3.amazonaws.com
s3_bucket = my-odoo-bucket
s3_key = YOUR_AWS_ACCESS_KEY
s3_secret = YOUR_AWS_SECRET_KEY
Next, you schedule aws s3 sync commands in cron to mirror your filestore directory:
aws s3 sync /srv/odoo/data/mydb/filestore s3://my-odoo-bucket/filestore --delete
Finally, you test restores by downloading a sample file. This setup gives you both local performance and cloud-based safety.
Caching and CDN Acceleration
First, you place an Nginx proxy in front of Odoo to cache static attachments. Next, you add a location block:
location /web/content/ {
proxy_pass http://odoo_backend;
proxy_cache filestore_cache;
proxy_cache_valid 200 1h;
}
Then, you configure proxy_cache_path with size limits. Moreover, you purge stale cache entries via an API call when attachments update. As a result, you reduce load on Odoo and speed up file delivery to end users.
Monitoring, Metrics, and Alerts
First, you install a filestore exporter for Prometheus. Next, you configure the exporter to read directory sizes:
- job_name: 'odoo_filestore'
static_configs:
- targets: ['localhost:9180']
Then, you create Grafana dashboards to track daily growth and peak usage. Furthermore, you define an alert rule:
alert: FilestoreHighUsage
expr: odool_filestore_size_bytes{db="mydb"} > 0.8 * odool_filestore_quota_bytes{db="mydb"}
for: 15m
Finally, you integrate alerts with Slack or email. This practice ensures you catch storage spikes before they impact performance.
Next Steps
First, review the Odoo official docs on file storage. Then, explore community modules for advanced S3, Azure, or Google Cloud integration. Moreover, consider writing custom scripts to tie filestore events into your existing DevOps pipelines. By doing so, you’ll master Odoo file management and keep your system robust and ready for growth.
Conclusion
Configure Odoo filestore ensures that you separate attachments from your database, improve performance, and simplify backups. Moreover, you maintain data integrity and streamline your Odoo operations. First, create your data_dir, then update odoo.conf. Next, restart Odoo and verify logs. Finally, implement backup and security best practices. With these steps, you configure Odoo filestore confidently and keep your system running smoothly.
For further reading, visit the Odoo Official Documentation.
Discover more from teguhteja.id
Subscribe to get the latest posts sent to your email.

