rsync - mkstemp failed: Permission denied (13)

2019-02-02 20:04发布

I have the following setup to periodically rsync files from server A to server B. Server B has the rsync daemon running with the following configuration:

read only = false
use chroot = false
max connections = 4
syslog facility = local5
log file = /var/adm/rsyncd.log
munge symlinks = false
secrets file = /etc/rsyncd.secrets
numeric ids = false
transfer logging = true
log format = %h %o %f %l %b


[BACKUP]
        path = /path/to/archive
        auth users = someuser

From server A I am issuing the following command:

rsync -adzPvO --delete --password-file=/path/to/pwd/file/pwd.dat /dir/to/be/backedup/ someuser@192.168.100.100::BACKUP

BACKUP directory is fully read/write/execute to everyone. When I run the rsync command from server A, I see:

afile.txt
         989 100%    2.60kB/s    0:00:00 (xfer#78, to-check=0/79)

for each and everyfile in the directory I wish to backup. It fails when I get to writing tmp files:

rsync: mkstemp "/.afile.txt.PZQvTe" (in BACKUP) failed: Permission denied (13)

Hours of googling later and I still can't resolve what seems to be a very simple permission issue. Advice? Thanks in advance.

Additional Information

I just noticed the following occurs at the beginning of the process:

rsync: failed to set permissions on "/." (in BACKUP): Permission denied (13)

Is it trying to set permission on "/"?

Edit

I am logged in as the user - someuser. My destination directory has full read/write/execute permission for everyone, including it's contents. In addition, the destination directory is owned by someuser and in someuser's group.

Follow up

I've found using SSH solves this

10条回答
地球回转人心会变
2楼-- · 2019-02-02 20:23

I encountered the same problem and solved it by chown the user of the destination folder. The current user does not have the permission to read, write and execute the destination folder files. Try adding the permission by chmod a+rwx <folder/file name>.

查看更多
我只想做你的唯一
3楼-- · 2019-02-02 20:23

I had the same error while syncing files inside of a Docker container and the destination was a mounted volume (Docker for mac), I run rsync via su-exec <user>. I was able to resolve it by running rsync as root with -og flags (keep owner and group for destination files).

I'm still not sure what caused that issue, the destination permissions were OK (I run chown -R <user> for destination dir before rsync), perhaps somehow related to Docker for Mac slow filesystem.

查看更多
Emotional °昔
4楼-- · 2019-02-02 20:25

This might not suit everyone since it does not preserve the original file permissions but in my case it was not important and it solved the problem for me. rsync has an option --chmod:

--chmod This option tells rsync to apply one or more comma-separated lqchmodrq strings to the permission of the files in the transfer. The resulting value is treated as though it was the permissions that the sending side supplied for the file, which means that this option can seem to have no effect on existing files if --perms is not enabled.

This forces the permissions to be what you want on all files/directories. For example:

rsync -av --chmod=Du+rwx SRC DST

would add Read, Write and Execute for the user to all transferred directories.

查看更多
Bombasti
5楼-- · 2019-02-02 20:28

Windows: Check permissions of destination folders. Take ownership if you must to give rights to the account running the rsync service.

查看更多
登录 后发表回答