5

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:

enter image description here

  • my 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. – matzeri Dec 22 '16 at 15:59
  • 1
    My 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. – Bob Stein Feb 23 '19 at 8:15
2

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

| improve this answer | |
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.

| improve this answer | |
0

For your consideration: I created a packaging of the Cygwin versions of OpenSSH and rsync:

https://github.com/Bill-Stewart/CygSSH

When you install, it sets the noacl option as default in the fstab file so that the Cygwin programs (including rsync) don't alter your file permissions.

I recommend SSH for rsync replication so that the data gets encrypted in transit.

| improve this answer | |
-1

I put windows on developer mode instead of using powershell and downloaded ubuntu off of the microsoft store, and then install VcXsrv and then install nautilus with ubuntu https://seanthegeek.net/234/graphical-linux-applications-bash-ubuntu-windows/

This is working very well, sometimes there is some file update errors with windows and ubuntu firefox has difficulty downloading files in ubuntu subsystem but overall it has sped up my speed in ubuntu instead of using cygwin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.