Linux rsync 打印“跳过非常规文件”以显示似乎是常规目录的内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7180420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:52:48  来源:igfitidea点击:

rsync prints "skipping non-regular file" for what appears to be a regular directory

linuxunixbackuprsyncdirectory

提问by Richard

I back up my files using rsync. Right after a sync, I ran it expecting to see nothing, but instead it looked like it was skipping directories. I've (obviously) changed names, but I believe I've still captured all the information I could. What's happening here?

我使用 rsync 备份我的文件。同步后,我运行它,希望看不到任何东西,但看起来它正在跳过目录。我(显然)更改了名称,但我相信我仍然可以捕获所有信息。这里发生了什么事?

$ ls -l /source/backup/myfiles
drwxr-xr-x 2 me me  4096 2010-10-03 14:00 foo
drwxr-xr-x 2 me me  4096 2011-08-03 23:49 bar
drwxr-xr-x 2 me me  4096 2011-08-18 18:58 baz

$ ls -l /destination/backup/myfiles
drwxr-xr-x 2 me me  4096 2010-10-03 14:00 foo
drwxr-xr-x 2 me me  4096 2011-08-03 23:49 bar
drwxr-xr-x 2 me me  4096 2011-08-18 18:58 baz

$ file /source/backup/myfiles/foo
/source/backup/myfiles/foo/: directory

Then I sync (expecting no changes):

然后我同步(预计没有变化):

$ rsync -rtvp /source/backup /destination
sending incremental file list
backup/myfiles
skipping non-regular file "backup/myfiles/foo"
skipping non-regular file "backup/myfiles/bar"

And here's the weird part:

这是奇怪的部分:

$ echo 'hi' > /source/backup/myfiles/foo/test
$ rsync -rtvp /source/backup /destination
sending incremental file list
backup/myfiles
backup/myfiles/foo
backup/myfiles/foo/test
skipping non-regular file "backup/myfiles/foo"
skipping non-regular file "backup/myfiles/bar"

So it worked:

所以它起作用了:

$ ls -l /source/backup/myfiles/foo
-rw-r--r-- 1 me me  3126091 2010-06-15 22:22 IMGP1856.JPG
-rw-r--r-- 1 me me  3473038 2010-06-15 22:30 P1010615.JPG
-rw-r--r-- 1 me me        3 2011-08-24 13:53 test

$ ls -l /destination/backup/myfiles/foo
-rw-r--r-- 1 me me  3126091 2010-06-15 22:22 IMGP1856.JPG
-rw-r--r-- 1 me me  3473038 2010-06-15 22:30 P1010615.JPG
-rw-r--r-- 1 me me        3 2011-08-24 13:53 test

but still:

但仍然:

$ rsync -rtvp /source/backup /destination
sending incremental file list
backup/myfiles
skipping non-regular file "backup/myfiles/foo"
skipping non-regular file "backup/myfiles/bar"

Other notes:

其他注意事项:

My actual directories "foo" and "bar" do have spaces, but no other strange characters. Other directories have spaces and have no problem. I 'stat'-ed and saw no differences between the directories that don't rsync and the ones that do.

我的实际目录“foo”和“bar”确实有空格,但没有其他奇怪的字符。其他目录有空格,没有问题。我 'stat'-ed 并看到没有 rsync 的目录和有的目录之间没有区别。

If you need more information, just ask.

如果您需要更多信息,请直接询问。

回答by Gauthic

Are you absolutely sure that it's not a symbolic link directory?

您绝对确定它不是符号链接目录吗?

try a:

尝试一个:

file /source/backup/myfiles/foo

to make sure it's a directory

确保它是一个目录

Also, it could very well be a loopback mount try

此外,它很可能是一个环回挂载尝试

mount

and make sure that /source/backup/myfiles/foo is not listed.

并确保 /source/backup/myfiles/foo 未列出。

回答by zaTricky

Are you absolutely sure those individual filesare not symbolic links?

您确定这些单个文件不是符号链接吗?

Rsync has a few useful flags such as -lwhich will "copy symlinks as symlinks". Adding -lto your command:

Rsync 有一些有用的标志,例如-l“将符号链接复制为符号链接”。添加-l到您的命令中:

rsync -rtvpl /source/backup /destination


I believe symlinks are skipped by default because they can be a security risk. Check the man page or --help for more info on this:

我相信默认情况下会跳过符号链接,因为它们可能存在安全风险。查看手册页或 --help 以获取更多信息:

rsync --help | grep link


To verify these are symbolic links or pro-actively to find symbolic links you can use fileor find:

要验证这些是符号链接或主动查找符号链接,您可以使用filefind

$ file /path/to/file
/path/to/file: symbolic link to `/path/file`
$ find /path -type l
/path/to/file

回答by Premjith

You can try the following, it will work

您可以尝试以下操作,它会起作用

rsync -rtvp /source/backup /destination

回答by mSatyam

You should try the below command, most probably it will work for you:

您应该尝试以下命令,它很可能对您有用:

rsync -ravz /source/backup /destination

回答by mSatyam

I personally always use this syntax in my script and works a treat to backup the intire system (skipping sys/* & proc/* nfs4/*)

我个人总是在我的脚本中使用这种语法,并尝试备份整个系统(跳过 sys/* & proc/* nfs4/*)

sudo rsync --delete --stats  --exclude-from $EXCLUDE -rlptgoDv / $TARGET/ | tee -a $LOG

Here is my script run by root's cron daily:

这是我每天由 root 的 cron 运行的脚本:

#!/bin/bash
#
NFS="/nfs4"
HOSTNAME=`hostname`
TIMESTAMP=`date "+%Y%m%d_%H%M%S"`
EXCLUDE="/home/gcclinux/Backups/root-rsync.excludes"
TARGET="${NFS}/${HOSTNAME}/SYS"
LOGDIR="${NFS}/${HOSTNAME}/SYS-LOG"
CMD=`/usr/bin/stat -f -L -c %T ${NFS}`

## CHECK IF NFS IS MOUNTED...

if [[ ! $CMD == "nfs" ]];then
    echo "NFS NOT MOUNTED"
    exit 1
fi

## CHECK IF LOG DIRECTORY EXIST

if [ ! -d "$LOGDIR" ]; then
    /bin/mkdir -p $LOGDIR
fi

## CREATE LOG HEADER
LOG=$LOGDIR/"rsync_result."$TIMESTAMP".txt"

echo "-------------------------------------------------------" | tee -a $LOG
echo `date` | tee -a $LOG
echo "" | tee -a $LOG

## START RUNNING BACKUP
/usr/bin/rsync --delete --stats  --exclude-from $EXCLUDE -rlptgoDv / $TARGET/ | tee -a $LOG