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

snap-sync --sudo: "rsync: mkstemp failed: Permission denied (13)" #109

Open
Zoddo opened this issue Jun 1, 2021 · 1 comment
Open

snap-sync --sudo: "rsync: mkstemp failed: Permission denied (13)" #109

Zoddo opened this issue Jun 1, 2021 · 1 comment

Comments

@Zoddo
Copy link

Zoddo commented Jun 1, 2021

Trying to do the initial backup of my root subvol with the following command...

sudo snap-sync -r storage --sudo

...produced the following error:

...
Performing backups...

Sending first snapshot for 'root' configuration...
At subvol //.snapshots/298/snapshot
7,88GiO 2:15:33 [1016KiB/s] [                                                                                            <=>                                            ]
rsync: mkstemp "/home/zoddo/LAPTOP_BACKUP/root/298/.info.xml.stGXBy" failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=v3.2.3]
Exited due to error on line 501.
exit status: 23
command: rsync -avzq "$new_info" "$remote":"$backup_location"
bash line: 0
function name: 

The remote name storage is an alias defined in /root/.ssh/config, which also forces the username zoddo, hence the use of --sudo.

As I understand, it tried to rsync the file with the remote user zoddo, but it didn't had the permission because the parent directory was created by root (through sudo).

I think this can be fixed by something like rsync --rsync-path="sudo rsync", but maybe there is a better way.

@Zoddo
Copy link
Author

Zoddo commented Jun 5, 2021

I managed to fix the issue with the following change:

--- /usr/bin/snap-sync	2021-01-30 09:37:09.000000000 +0100
+++ ./snap-sync	2021-06-02 13:56:40.222397205 +0200
@@ -497,10 +497,15 @@
     if [[ -z $remote ]]; then
         cp "$new_info" "$backup_location"
     else
+        remote_rsync="rsync"
+        if [[ $sudo -eq 1 ]]; then
+            remote_rsync="sudo rsync"
+        fi
+
         if [[ -z $port ]]; then
-            rsync -avzq "$new_info" "$remote":"$backup_location"
+            rsync -avzq --rsync-path="$remote_rsync" "$new_info" "$remote":"$backup_location"
         else
-            rsync -avzqe "ssh -p $port" "$new_info" "$remote":"$backup_location"
+            rsync -avzqe "ssh -p $port" --rsync-path="$remote_rsync" "$new_info" "$remote":"$backup_location"
         fi
     fi
 

I'm not a bash expert, there is probably a cleaner way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant