背景
我在Windows 10上使用rsync / cygwin将所有本地文件(源)备份到外部硬盘驱动器(目标)。我用过这个指南 http://www.howtogeek.com/175008/the-non-beginners-guide-to-syncing-data-with-rsync/ 作为如何使用rsync / cygwin进行备份的教程。注意:我的外部硬盘驱动器格式化为NTFS。
在第一次备份时,我手动将所需的文件夹复制/粘贴到目标。所有后续备份均使用rsync完成,如下所述。
我使用rsync / cygwin的备份方法
在Windows上,我使用rsync命令创建了一个backup.bat文件,这样我就可以快速插入外部驱动器并开始备份。下面是我的backup.bat文件的示例,其中C是我的本地驱动器,E是我的外部驱动器。
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
为了确保我没有权限问题,我将C:\ cygwin64 \ etc \ fstab文件编辑到下面:
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
问题/问题
我遇到的问题是我经常看到“Permission denied(13)”错误。以下是rsync日志的摘录。请注意如何备份某些文件/文件夹而不会出现错误。但是,有一些文件/文件夹会提供权限错误。
...
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
...
故障排除
要进行故障排除,我在Windows资源管理器(在外部硬盘驱动器上)导航到其中一个具有权限错误的文件夹。下面是我得到的对话通知的屏幕截图。当我单击“继续”以获得权限时,该文件夹将打开,但该文件夹为空。当我重新运行rsync命令(backup.bat)时,该文件夹中的文件被正确备份而没有错误。
截图: