Yenthe666 / auto_backup

Automated database backups from Odoo, both locally and on an FTP server
MIT License
251 stars 281 forks source link

permission denied while run the scheduled action manually in odoo 13 #195

Closed dbs-devops closed 3 years ago

dbs-devops commented 3 years ago

i configured sftp perfectly. while i running the scheduled action, its shows the permission denied error, i can't take it up further. please help me to fix this..... and also i checked the permission access to the user,

Error: Odoo Server Error

Traceback (most recent call last): File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/tools/safe_eval.py", line 351, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "", line 1, in File "/home/rsa-key-20200714/inspire_custom_modules/auto_backup/models/db_backup.py", line 124, in schedule_backup os.makedirs(rec.folder) File "/opt/bitnami/python/lib/python3.7/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/opt/bitnami/python/lib/python3.7/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/opt/bitnami/python/lib/python3.7/os.py", line 223, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/home/user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 624, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/tools/pycompat.py", line 14, in reraise raise value File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 669, in dispatch result = self._call_function(self.params) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 350, in _call_function return checked_call(self.db, *args, *kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/service/model.py", line 94, in wrapper return f(dbname, args, kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 339, in checked_call result = self.endpoint(*a, kw) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 915, in call return self.method(*args, *kw) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/http.py", line 515, in response_wrap response = f(args, kw) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/addons/web/controllers/main.py", line 1326, in call_button action = self._call_kw(model, method, args, kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/addons/web/controllers/main.py", line 1314, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/api.py", line 387, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/api.py", line 374, in _call_kw_multi result = method(recs, *args, **kwargs) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/addons/base/models/ir_cron.py", line 83, in method_direct_trigger self.with_user(cron.user_id).ir_actions_server_id.run() File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/addons/base/models/ir_actions.py", line 545, in run res = func(action, eval_context=eval_context) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/addons/base/models/ir_actions.py", line 430, in run_action_code_multi safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True) # nocopy allows to return 'action' File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/tools/safe_eval.py", line 374, in safe_eval pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2]) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/tools/pycompat.py", line 13, in reraise raise value.with_traceback(tb) File "/opt/bitnami/apps/odoo/lib/odoo-13.0.post20200715-py3.7.egg/odoo/tools/safe_eval.py", line 351, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "", line 1, in File "/home/rsa-key-20200714/inspire_custom_modules/auto_backup/models/db_backup.py", line 124, in schedule_backup os.makedirs(rec.folder) File "/opt/bitnami/python/lib/python3.7/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/opt/bitnami/python/lib/python3.7/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/opt/bitnami/python/lib/python3.7/os.py", line 223, in makedirs mkdir(name, mode) ValueError: <class 'PermissionError'>: "13 Permission denied" while evaluating 'model.schedule_backup()'

image

Yenthe666 commented 3 years ago

Well, the error is transparent. Your user does not have access to write within this folder. I'm 100% sure that the user user is not your user that runs Odoo and thus that Odoo user has no rights here?

altaolano commented 3 years ago

hello, how to know which user is running odoo ?

Yenthe666 commented 3 years ago

Err... because you installed it lol? you can see it by doing ps aux | grep odoo for example or by checking the rights/ownership of the Odoo folder. Anyways, this is all pretty much out of scope of our module & people keep tripping up over this but it is basic Linux so there is not much I can do.

IT-LCEC commented 3 years ago

Anyways, this is all pretty much out of scope of our module & people keep tripping up over this but it is basic Linux so there is not much I can do.

So if folks keep tripping up on it, why not add it to your great tutorial? I followed it and have the same issue using odoo in docker container.

Yenthe666 commented 3 years ago

The problem is that if I have to add every pitfall / thing to check to my tutorial it will become a 30 page long book which nobody ever reads anymore. I kept it short & lean for a reason, so people can start it in as minimal time as possible. This is more OS knowledge then Odoo too anyways.

IT-LCEC commented 3 years ago

In case others happen upon this thread. Here is what I did.

mgmnrn commented 3 years ago

In case others happen upon this thread. Here is what I did.

  • Create a folder while in the Odoo container logged in as root: /etc/odoo/backups
  • set permissions on the backups folder like this:

    • chmod o+w /etc/odoo/backups
    • chmod g-x /etc/odoo/backups
  • Verify the permissions by running: ls -l /etc/odoo

    • drwxr--rwx 2 root root 4096 Mar 19 14:09 backups
  • Edit the backup settings and set folder to /etc/odoo/backups

Thank you

Ultios commented 11 months ago

I can testify that people are tripping up on this often. Usually if Chmod is needed for installation of a package or module, it will show the command in the installation docs, e.g. docker engine installation. If the reason is "it's a basic linux", then most installations are "basic linux" things. All in all, this is a bad practice on documentation.