Backup Odoo db from within odoo

允我心安 提交于 2019-12-01 03:48:47

By using this module you can backup your database periodically

https://www.odoo.com/apps/modules/7.0/crontab_config/ (v7)

you can also test this module

https://www.odoo.com/apps/modules/6.1/db_backup_ept/ (v6 it can be miggrated to v7)

in your case you can add button to execute the function that will be executed by the schedular.

You can use a private browser session to access the Database menu, from the login screen, and perform the the backup form there (you need to know the master password to access that, defined in the server configuration file).

Go to your_odoo_instance/web/database/manager where you can see all your installed databases:

Odoo's Database Manager - Backup

You will need your defined master password for this task. If you can't remember it, have a look at your odoo.conf file in your server and check the 'admin_passwd' entry.

You can take database backup from "Database Management" in odoo..

type following link in browser,

http://localhost:8069/web/database/manager

just replace your ip and port in aboves link, you will get screen for database management, you can perform following operations related to database

  • Create
  • Duplicate
  • Drop
  • Backup
  • Password
  • Restore

You can use the CURL to download the full backup (assets + DB), this method is comparatively faster than pg_dump.

curl -X POST \
-F "master_pwd=${ADMIN_PASSWORD}" \
-F "name=${ODOO_DATABASE}" \
-F "backup_format=zip" \
-o ${BACKUP_DIR}/${ODOO_DATABASE}.$(date +%F-%T).zip \
${HOST}/web/database/backup

You can wrap inside a custom (your own) Odoo add-on if you wish to. Hope this helps.

Add a button somewhere and call a controller like this one.

@http.route('/backup/download', auth="user", type='http')
        def backup(self, **kw):
            ts = datetime.datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S")
            filename = "%s_%s.zip" % (request.env.cr.dbname, ts)
            headers = [
                ('Content-Type', 'application/octet-stream; charset=binary'),
                ('Content-Disposition', content_disposition(filename)),
            ]
            dump_stream = db.dump_db(request.env.cr.dbname, None)
            response = werkzeug.wrappers.Response(dump_stream, headers=headers, direct_passthrough=True)
            return response

For backup, you can go to this link http://localhost:8069/web/database/manager.

  • You can create a backup from there.
  • You can restore your pre existing backup also.

Important- Before that just set your master password for your Database to avoid consequences in future.

If you want to change particular models or fields while logged in. You can do it by export/import action provided by Odoo. After exporting data from local you can import it on your server for that you have to validate it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!