Reputation: 148
I want to transfer an Odoo Application from Development to Production system. For that purpose I want to take a backup of my database and I am taking backup from UI.
On taking backup this is the error that shows on UI
Database backup error: 'NoneType' object has no attribute '__getitem__'
2016-03-19 06:00:02,351 2864 ERROR ? openerp.addons.web.controllers.main: Database.backup
Traceback (most recent call last):
File "C:\Odoo 9.0-20160127\server\openerp\addons\web\controllers\main.py", line 693, in backup
File "C:\Odoo 9.0-20160127\server\openerp\addons\web\controllers\main.py", line 422, in content_disposition
TypeError: 'NoneType' object has no attribute '__getitem__'
2016-03-19 06:00:02,413 2864 INFO ? werkzeug: 127.0.0.1 - - [19/Mar/2016 06:00:02] "POST /web/database/backup HTTP/1.1" 200 -
Upvotes: 1
Views: 1631
Reputation: 11
It is enough to visit any database login screen and then go back to backup which will be working. Additional cookie gets set in any login screen which is used by backup after.
If you have some automation using curl then you need to curl to /web?db={database name} which will get you redirected to login page with db set and then using same curl session with saved cookie do a curl post to /web/database/backup. Something like this with php:
$cookie_file = dirname(__FILE__) . "/" . date('Y-m-dH:i:s') . '.txt';
$ch = curl_init($odooHost . "/web?db={$databaseName}");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
$content = curl_exec($ch);
if(curl_errno($ch)) {
echo 'error:' . curl_error($ch);
curl_close($ch);
unlink($cookie_file);
return;
} else {
curl_setopt($ch, CURLOPT_URL, $odooHost . "/web/database/backup");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"master_pwd={$password}&name={$databaseName}&backup_format=zip");
$content = curl_exec($ch);
After this in $content you should have the backed up db. Save it to file or whatever your needs.
Upvotes: 1
Reputation: 195
You should login as admin first to your database, and going back to backup Database.
Regards, FTK
Upvotes: 0