{"id":634,"date":"2025-05-09T14:55:22","date_gmt":"2025-05-09T14:55:22","guid":{"rendered":"https:\/\/remote-support.space\/wordpress\/?p=634"},"modified":"2025-05-09T21:53:24","modified_gmt":"2025-05-09T21:53:24","slug":"how-to-backup-a-local-odoo-server","status":"publish","type":"post","link":"http:\/\/remote-support.space\/wordpress\/2025\/05\/09\/how-to-backup-a-local-odoo-server\/","title":{"rendered":"How to backup a local odoo server."},"content":{"rendered":"\n<p>To back up a locally hosted Odoo instance, follow these steps to ensure all critical components (database, filestore, custom code, and configurations) are safely backed up:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Backup the Odoo Database<\/strong><\/h3>\n\n\n\n<p>Odoo uses <strong>PostgreSQL<\/strong> for its database. Use <code>pg_dump<\/code> to create a SQL dump of your database.<\/p>\n\n\n\n<p><strong>Command:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pg_dump -U &lt;postgres_username&gt; -F p &lt;database_name&gt; &gt; \/path\/to\/backup\/odoo_db_$(date +%Y-%m-%d).sql<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace <code>&lt;postgres_username><\/code> and <code>&lt;database_name><\/code> with your PostgreSQL credentials.<\/li>\n\n\n\n<li>Example: <code>pg_dump -U odoo -F p odoo_production > ~\/backups\/odoo_db_2023-10-01.sql<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Backup the Filestore<\/strong><\/h3>\n\n\n\n<p>Odoo stores attachments (e.g., documents, images) in the <strong>filestore<\/strong> directory. Locate it in your Odoo config file (<code>odoo.conf<\/code>):<\/p>\n\n\n\n<p><strong>Command:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Find the filestore path (default: ~\/.local\/share\/Odoo\/filestore)\ngrep data_dir \/etc\/odoo\/odoo.conf\n\n# Copy the filestore directory\ncp -r ~\/.local\/share\/Odoo\/filestore\/&lt;database_name&gt; \/path\/to\/backup\/filestore_$(date +%Y-%m-%d)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Backup Custom Modules\/Code<\/strong><\/h3>\n\n\n\n<p>If you\u2019ve added custom modules or modified Odoo source code, back up these directories:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Custom modules (e.g., <code>~\/odoo-custom-addons<\/code>)<\/li>\n\n\n\n<li>Odoo source code (if modified, e.g., <code>\/opt\/odoo\/odoo<\/code>).<\/li>\n<\/ul>\n\n\n\n<p><strong>Command:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -czvf \/path\/to\/backup\/odoo_custom_code_$(date +%Y-%m-%d).tar.gz \\\n  ~\/odoo-custom-addons \\\n  \/opt\/odoo\/odoo<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Backup Configuration Files<\/strong><\/h3>\n\n\n\n<p>Back up your Odoo configuration file and any server configurations (e.g., Nginx\/Apache, service files).<\/p>\n\n\n\n<p><strong>Command:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp \/etc\/odoo\/odoo.conf \/path\/to\/backup\/odoo.conf_$(date +%Y-%m-%d)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Automate Backups (Optional)<\/strong><\/h3>\n\n\n\n<p>Create a script (<code>\/path\/to\/backup_odoo.sh<\/code>) to automate daily backups:<\/p>\n\n\n\n<p><strong>Script Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nBACKUP_DIR=\"\/path\/to\/backups\"\nDB_NAME=\"odoo_production\"\nDB_USER=\"odoo\"\nDATE=$(date +%Y-%m-%d)\n\n# Backup database\npg_dump -U $DB_USER -F p $DB_NAME &gt; $BACKUP_DIR\/odoo_db_$DATE.sql\n\n# Backup filestore\nrsync -avr ~\/.local\/share\/Odoo\/filestore\/$DB_NAME $BACKUP_DIR\/filestore_$DATE\n\n# Backup custom code\ntar -czvf $BACKUP_DIR\/odoo_custom_code_$DATE.tar.gz ~\/odoo-custom-addons\n\n# Backup config\ncp \/etc\/odoo\/odoo.conf $BACKUP_DIR\/odoo.conf_$DATE\n\n# Delete backups older than 30 days\nfind $BACKUP_DIR -type f -mtime +30 -delete<\/code><\/pre>\n\n\n\n<p><strong>Add to Cron (run daily):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -e\n# Add this line to run at 2 AM daily:\n0 2 * * * \/bin\/bash \/path\/to\/backup_odoo.sh<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Restoring from Backup<\/strong><\/h3>\n\n\n\n<p>To restore Odoo from a backup:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Database:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   createdb -U &lt;postgres_user&gt; &lt;new_db_name&gt;\n   psql -U &lt;postgres_user&gt; &lt;new_db_name&gt; &lt; \/path\/to\/backup\/odoo_db_2023-10-01.sql<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Filestore:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   cp -r \/path\/to\/backup\/filestore_2023-10-01 ~\/.local\/share\/Odoo\/filestore\/&lt;new_db_name&gt;<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Custom Code\/Configs:<\/strong><br>Extract the <code>.tar.gz<\/code> file and replace the relevant directories\/configs.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Additional Tips<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use Odoo\u2019s Built-in Backup:<\/strong><br>Go to <code>Settings > Database > Backup<\/code> in the Odoo web interface to download a <code>.zip<\/code> backup (includes database + filestore).<\/li>\n\n\n\n<li><strong>Encrypt Backups:<\/strong> Use tools like <code>gpg<\/code> for sensitive data.<\/li>\n\n\n\n<li><strong>Offsite Storage:<\/strong> Store backups in cloud storage (e.g., AWS S3, Google Drive) or a remote server.<\/li>\n\n\n\n<li><strong>Test Restores:<\/strong> Periodically verify backups by restoring them to a test environment.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>By following these steps, you\u2019ll ensure a complete backup of your Odoo instance, minimizing downtime and data loss risks.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To back up a locally hosted Odoo instance, follow these steps to ensure all critical components (database, filestore, custom code, and configurations) are safely backed up: 1. Backup the Odoo Database Odoo uses PostgreSQL for its database. Use pg_dump to create a SQL dump of your database. Command: 2. Backup the Filestore Odoo stores attachments [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-ict"],"_links":{"self":[{"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":1,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":635,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/634\/revisions\/635"}],"wp:attachment":[{"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}