Skip to Content
Menu
This question has been flagged
2 Replies
6251 Views

i did a backup with db.py help 

# Backup DB
# service/db.py: def exp_dump(db_name):
def backup(args):
with open(args.filedump, 'w') as f:
f.write(server.dump(args.superpwd, args.database).decode('base64'))
if f:
print 'Database Backup File Name: %s' % f.name
sys.exit(0)
else:
sys.exit(2)

This Works great, the zip file created works in the gui at restore perfectly, now i want to write another script to use the restore function, but i am getting an error 

used this

# Restore DB
# service/db.py: def exp_restore(db_name, data, copy=False):
def restore(args):
print 'Restore Database: %s' % args.database
if server.restore(args.superpwd, args.database, args.filedump):
sys.exit(0)
else:
sys.exit(2)

this raises the error of the following, anyone a short IDEA of what the problem could be?

Traceback (most recent call last):
  File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 108, in <module>
    args.func(args)
  File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 57, in restore
    if server.restore(args.superpwd, args.database, args.filedump):
  File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1587, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault Incorrect padding: 'Traceback (most recent call last):\n  File "/opt/odoo_v8.0/odoo/openerp/service/wsgi_server.py", line 75, in xmlrpc_return\n    result = openerp.http.dispatch_rpc(service, method, params)\n  File "/opt/odoo_v8.0/odoo/openerp/http.py", line 115, in dispatch_rpc\n    result = dispatch(method, params)\n  File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 73, in dispatch\n    return fn(*params)\n  File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 215, in exp_restore\n    data_file.write(data.decode(\'base64\'))\n  File "/usr/lib/python2.7/encodings/base64_codec.py", line 42, in base64_decode\n    output = base64.decodestring(input)\n  File "/usr/lib/python2.7/base64.py", line 321, in decodestring\n    return binascii.a2b_base64(s)\nError: Incorrect padding\n'>Traceback (most recent call last):
File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 108, in <module>
args.func(args)
File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 57, in restore
if server.restore(args.superpwd, args.database, args.filedump):
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault Incorrect padding: 'Traceback (most recent call last):\n File "/opt/odoo_v8.0/odoo/openerp/service/wsgi_server.py", line 75, in xmlrpc_return\n result = openerp.http.dispatch_rpc(service, method, params)\n File "/opt/odoo_v8.0/odoo/openerp/http.py", line 115, in dispatch_rpc\n result = dispatch(method, params)\n File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 73, in dispatch\n return fn(*params)\n File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 215, in exp_restore\n data_file.write(data.decode(\'base64\'))\n File "/usr/lib/python2.7/encodings/base64_codec.py", line 42, in base64_decode\n output = base64.decodestring(input)\n File "/usr/lib/python2.7/base64.py", line 321, in decodestring\n return binascii.a2b_base64(s)\nError: Incorrect padding\n'>

Thanks in Advance cheers 

Avatar
Discard
Best Answer

You need to encode again to base64, because Odoo is trying to decode it

Avatar
Discard
Author

right now i am doing the whole restore like it is done from "eqms" Thanks to Martin for this see this for detail https://github.com/equitania/odoo-addons/blob/8.0/scripts/restore-zip.sh

Author Best Answer

Perfect thanks i just added the encode and works fine now

def restore(args):
print 'Restore Database: %s' % args.database
if server.restore(args.superpwd, args.database, (args.filedump).encode('base64')):
sys.exit(0)
else:
sys.exit(2)
but raising another error message now, even the restore has been done and the database is restored, any idea ? 
Traceback (most recent call last):
File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 114, in <module>
args.func(args)
File "/opt/odoo_v8.0/TOOLS/db-tools.py", line 49, in restore
if server.restore(args.superpwd, args.database, (args.filedump).encode('base64')):
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault Postgres subprocess ('/usr/bin/pg_restore', '--username=o8_autoupdatetools2', '--host=127.0.0.1', '--dbname=o8_autoupdatetools2', '--no-owner', '/tmp/tmphlEcTF') error 1: 'Traceback (most recent call last):\n File "/opt/odoo_v8.0/odoo/openerp/service/wsgi_server.py", line 75, in xmlrpc_return\n result = openerp.http.dispatch_rpc(service, method, params)\n File "/opt/odoo_v8.0//odoo/openerp/http.py", line 115, in dispatch_rpc\n result = dispatch(method, params)\n File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 73, in dispatch\n return fn(*params)\n File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 217, in exp_restore\n restore_db(db_name, data_file.name, copy=copy)\n File "/opt/odoo_v8.0/odoo/openerp/service/db.py", line 260, in restore_db\n if openerp.tools.exec_pg_command(pg_cmd, *pg_args):\n File "/opt/odoo_v8.0/odoo/openerp/tools/misc.py", line 128, in exec_pg_command\n raise Exception(\'Postgres subprocess %s error %s\' % (args2, rc))\nException: Postgres subprocess (\'/usr/bin/pg_restore\', \'--username=o8_autoupdatetools2\', \'--host=127.0.0.1\', \'--dbname=o8_autoupdatetools2\', \'--no-owner\', \'/tmp/tmphlEcTF\') error 1\n'>
DEBUG: args: Namespace(baseport='10369', database='o8_autoupdatetools2', filedump='/opt/odoo_v8.0/o8_autoupdatetools2/BACKUP/o8_autoupdatetools2.zip', func=<function restore at 0x7fe6dd953230>, superpwd='xxxxx') server: <ServerProxy for localhost:10369/xmlrpc/db> Restore Database: o8_autoupdatetools2
Avatar
Discard

That error didn't tell me anything, check PostgresSQL logs for more or try to manually run the generated command "/usr/bin/pg_restore --username=o8_autoupdatetools2 --host=127.0.0.1 --dbname=o8_autoupdatetools2 --no-owner /tmp/tmphlEcTF". Replace "/tmp/tmphlEcTF" with a file containing the dump and see what error could be happening, create a new bd for that and also replace it in the command before

Author

when i do a creation like this ${INSTANCE_PATH}/TOOLS/db-tools.py -b ${BASEPORT69} -s ${SUPER_PASSWORD} newdb -d ${DBNAME} -p 'xxxx' works great, when i after this do the restore it correctly tells me database exists. When i do not create it i get the error above xmlrpclib.Fault:

I think that you need to first create the db, then next do a restore on it, it's mandatory that the database need to exist

Related Posts Replies Views Activity
3
Jul 24
3369
1
May 21
2550
1
Mar 24
5089
3
Aug 16
3299
0
Mar 16
3313