I am using rsync to backup some folders in my home directory to a remote server using the following commands:
cd
rsync -Favz --inplace --delete --delete-excluded folder1 folder2 folder3 remote-server:/remote/path/
All files are owned by my user, both locally and remotely.
It works fine except with files that have mode r--r--r--, even though my user is the owner of those files and the parent directory.
This is what rsync reports for those files:
rsync: open "/remote/path/somefolder/somefile" failed: Permission denied (13)
...
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
As a temporary solution I am able to log on the remote machine (same user), delete the files and re-run rsync which will then create those files in those modes, however next time I run the script it will fail again.
Is there a way to have rsync overwrite non-writable files on the remote side (or delete them and create them again) or do I have to settle with first deleting them remotely and then running the backup script?
This question is quite similar to How to backup /etc/{,g}shadow files with 0000 permission? except that the latter talks about non-readable files and my question is about readable but non-writable files.
namei -mo somefolder/somepath
if it isn't too private).