Rsync and Cygwin based backup on Windows gives permission denied errors
Solution 1
I managed to find a solution which currently works for me. I am unsure if this is a guaranteed correct approach.
In order to avoid permission issues, I need to add the following to my rsync command: --no-p --chmod=ugo=rwX
. Thus, my rsync backup command should look like the following:
rsync -avhP --no-p --chmod=ugo=rwX --delete --log-file="/cygdrive/C/Users/MyUsername/rsync-backup-log.txt" "/cygdrive/C/Users/MyUsername/Folder A" "/cygdrive/E/Backup/"
Credit to this solution goes to the following answer in a similar post: https://superuser.com/a/69764/607501
Solution 2
As you have already indicated,
--no-p
with --chmod=ugo=rwX
will set all permission bits.
However, if you want more fine-grain control over the permissions for the new directory, you can use other arguments for --chmod=
The guide you linked actually has an example of this (may have been added after you used it): --chmod=Du=rwx,Dgo=rx,Fu=rw
man rsync
contains lots of information about this option.
Related videos on Youtube
Zythyr
Updated on September 18, 2022Comments
-
Zythyr over 1 year
Background
I use rsync/cygwin on Windows 10 to backup all my local files (source) to an external hard drive (destination). I used this guide http://www.howtogeek.com/175008/the-non-beginners-guide-to-syncing-data-with-rsync/ as a tutorial on how to use rsync/cygwin for backing up. Note: My external hard drive is formatted to NTFS.
On the very first backup, I manually copied/pasted the desired folders to the destination. All subsequent backups are done using rsync as described below.
My backup method using rsync/cygwin
On Windows, I created a backup.bat file with my rsync commands so I can can quickly plug in my external drive and start the backup. Below is an example of my backup.bat file, where C is my local drive, and E is my external drive.
pause rsync -avhP --delete --log-file="/cygdrive/C/Users/MyUsername/rsync-backup-log.txt" "/cygdrive/C/Users/MyUsername/Folder A" "/cygdrive/E/Backup/" rsync -avhP --delete --log-file="/cygdrive/C/Users/MyUsername/rsync-backup-log.txt" "/cygdrive/C/Users/MyUsername/Folder B" "/cygdrive/E/Backup/" rsync -avhP --delete --log-file="/cygdrive/C/Users/MyUsername/rsync-backup-log.txt" "/cygdrive/C/Users/MyUsername/Folder C" "/cygdrive/E/Backup/" pause
To ensure I don't have permission issues, I edited my C:\cygwin64\etc\fstab file to below:
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
Problem/issue
The issue I am having is that I often see "Permission denied (13)" errors. Below is an extract of the rsync log. Notice how some files/folder are backed up without errors. However, there are some files/folders that give permission errors.
... 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5678.JPG 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5679.JPG 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5680.JPG 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5681.JPG 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5682.JPG 2016/12/17 15:57:04 [2968] >f+++++++++ Documents/Subfolder A/IMG_5996.JPG ... 2016/12/17 15:58:03 [6052] >f+++++++++ Folder B/Subfolder C/FileD.docx 2016/12/17 15:58:03 [6052] cd+++++++++ Folder B/Subfolder C/Subfolder E/ 2016/12/17 15:58:04 [6052] >f+++++++++ Folder B/Subfolder F/FileG.docx 2016/12/17 15:58:04 [6052] rsync: mkstemp "/cygdrive/E/Backup/Folder B/Subfolder C/.FileD.docx.dBBzQZ" failed: Permission denied (13) 2016/12/17 15:58:07 [6052] rsync: mkstemp "/cygdrive/E/Backup/Folder B/Subfolder F/.FileG.docx.8DkCUR" failed: Permission denied (13) 2016/12/17 15:58:07 [6052] rsync: recv_generator: mkdir "/cygdrive/E/Backup/Folder B/Subfolder H/Subfolder J" failed: Permission denied (13) 2016/12/17 15:58:07 [6052] *** Skipping any contents from this failed directory *** 2016/12/17 15:58:07 [6052] >f+++++++++ Folder B/Subfolder H/FileK.xlsx 2016/12/17 15:58:07 [6052] cd+++++++++ Folder B/Subfolder H/Subfolder J/ 2016/12/17 15:58:07 [6052] rsync: mkstemp "/cygdrive/E/Backup/Folder B/Subfolder H/.FileK.xlsx.WQa396" failed: Permission denied (13) 2016/12/17 15:58:07 [6052] sent 91.52M bytes received 1.79K bytes 9.63M bytes/sec ...
Troubleshooting
To troubleshoot, I navigated to one of the folders with the permission error in Windows Explorer (on the external hard drive). Below is a screenshot of the dialog notification I get. When I click Continue to gain permission, the folder opens, but its empty. When I re-run rsync command (backup.bat), the files in that folder are properly backed up without error.
Screenshot:
-
matzeri over 7 yearsmy 2c$: for local backup, specially from data in the user folder, it could be better to use windows robocopy. It has less ACL problems and it is substantial faster than cygwin rsync.
-
Bob Stein about 5 yearsMy error was
rsync: send_files failed to open "/cygdrive/...": Permission denied (13)
. So send_files not mkstemp. Problem on the Windows side. So different situation, but for posterity, my solution was to right-click cmd.exe and Run as administrator.
-