Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied when copying backup to samba share #64

Closed
AnonymousRetard opened this issue Jul 31, 2022 · 2 comments
Closed

Permission denied when copying backup to samba share #64

AnonymousRetard opened this issue Jul 31, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@AnonymousRetard
Copy link

Not sure if this actually affects anything other than creating ugly error messages in the log every time the scheduled backup runs. But it seems like the chmod_func fails with error "Permission denied" every time a backup has been created and copied to my download_path, which is a mounted samba share.

Is it really necessary to copy all permission bits to the download_path? It seems like if shutil.copyfile would be used instead of shutil.copy then it wouldn't try to run chmod_func and it wouldn't generate any error messages.

See: https://stackoverflow.com/questions/11835833/why-would-shutil-copy-raise-a-permission-exception-when-cp-doesnt

When I try to run chmod or chown on any files on the mounted share as root it doesn't generate any errors but also nothing at all happens. The owner user and group and permissions on all files are controlled by options in /etc/fstab and it's not possible to change on any file or folder on the share.

jul 30 02:00:24 htpc hass[1030536]: 2022-07-30 02:00:23 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
jul 30 02:00:24 htpc hass[1030536]: Traceback (most recent call last):
jul 30 02:00:24 htpc hass[1030536]:   File "/etc/homeassistant/custom_components/auto_backup/handlers.py", line 188, in download_backup
jul 30 02:00:24 htpc hass[1030536]:     shutil.copy(backup.path, destination)
jul 30 02:00:24 htpc hass[1030536]:   File "/usr/lib/python3.9/shutil.py", line 428, in copy
jul 30 02:00:24 htpc hass[1030536]:     copymode(src, dst, follow_symlinks=follow_symlinks)
jul 30 02:00:24 htpc hass[1030536]:   File "/usr/lib/python3.9/shutil.py", line 317, in copymode
jul 30 02:00:24 htpc hass[1030536]:     chmod_func(dst, stat.S_IMODE(st.st_mode))
jul 30 02:00:24 htpc hass[1030536]: PermissionError: [Errno 1] Operation not permitted: '/mnt/DroboFS/Shares/Our_stuff/homeassistant-backups/Core_2022_7_7.tar'
@jcwillox
Copy link
Owner

jcwillox commented Aug 8, 2022

Yeah, that makes sense I think I was actually planning to use shutil.copy2 to preserve metadata as well but had no idea that would cause errors on samba shares. I'd expect it to fail gracefully when the platform doesn't support it.

As you said there's no real reason to copy the permission bits so I'll switch it to shutil.copyfile.

@jcwillox jcwillox added the bug Something isn't working label Aug 8, 2022
@jcwillox
Copy link
Owner

jcwillox commented Aug 9, 2022

This should be fixed in version 1.2.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants