Backup Odoo db from within odoo

后端 未结 8 859
北恋
北恋 2021-01-11 14:22

I need to backup the current db while logged into odoo. I should be able to do it using a button, so that suppose I click on the button, it works the same way as odoo defaul

相关标签:
8条回答
  • 2021-01-11 15:16

    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
    
    0 讨论(0)
  • 2021-01-11 15:18

    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).

    0 讨论(0)
提交回复
热议问题