Rclone备份排除指定目录 巨坑我帮你们踩完了 - Assbbs
Rclone备份排除指定目录 巨坑我帮你们踩完了…… 例如我想备份 /www 目录并排除 /www/pics 这个子目录 那么相应的语句应该是: --exclude /pics/ 几个要点: 1. /pics是相对于备份路径而言,备份目录是/www,那这个就不能是/www/pics,而是相对于/www下的/pics。 2. /pi…
Rclone备份排除指定目录 巨坑我帮你们踩完了…… 例如我想备份 /www 目录并排除 /www/pics 这个子目录 那么相应的语句应该是: --exclude /pics/ 几个要点: 1. /pics是相对于备份路径而言,备份目录是/www,那这个就不能是/www/pics,而是相对于/www下的/pics。 2. /pics必须以/开头的绝对路径,否则如果是pics,则会忽略掉所有目录下的pics子目录。 3. 尾部要接/ 才能达到忽略目录下所有内容和所有子目录递归忽略的效果。 这玩意配置起来实在是太反人类了…… 官网解释: If the filter pattern starts with a / then it only matches at the top level of the directory tree, relative to the root of the remote not necessarily the root of the drive . If it does not start with / then it is matched starting at the end of the path/file name but it only matches a complete path element - it must match from a / separator or the beginning of the path/file. file.jpg - matches "file.jpg" - matches "directory/file.jpg" - doesn't match "afile.jpg" - doesn't match "directory/afile.jpg" /file.jpg - matches "file.jpg" in the root directory of the remote - doesn't match "afile.jpg" - doesn't match "directory/file.jpg" The top level of the remote may not be the top level of the drive. 以下是ChatGPT解答,看看是怎么给人带进坑里的: rclone是一个命令行程序,用于同步和备份数据,可以使用它来排除指定目录。 要在rclone备份中排除特定目录,可以使用 --exclude 选项。该选项指定要排除的文件或目录的模式。模式可以是通配符模式,也可以是正则表达式模式。 以下是使用 --exclude 选项来排除特定目录的示例命令: rclone sync /path/to/source remote:destination --exclude dir1/ --exclude dir2/ 上面的命令将同步 /path/to/source 目录中的所有内容到名为 destination 的远程位置,但是排除 dir1 和 dir2 目录及其所有子目录的内容。 --exclude 选项可以多次使用,以便排除多个目录或文件。 在rclone中,通配符 表示匹配任意子目录,而 表示匹配零个或多个字符。因此, dir1/ 表示排除 dir1 目录及其所有子目录,而 dir1/ 则只表示排除 dir1 目录中的直接子目录和文件,而不包括子目录中的内容。 所以在上面的示例命令中, --exclude dir1/ 表示排除 dir1 目录及其所有子目录的内容, --exclude dir2/ 表示排除 dir2 目录及其所有子目录的内容。 乍一看很对,不过目录那块是不是有问题? 于是我提问“dir1/ 不是会匹配每个目录下的 dir1 吗”,AI答曰:( ChatGPT给出了错误答案! ) 您说的是正确的。如果使用 dir1/ ,它将排除包含名为 dir1 的任何目录,而不仅仅是排除 /path/to/source/dir1 目录。因此,如果您想要排除仅位于 /path/to/source 目录中的 dir1 目录,可以使用 dir1/ 。 因此,以下是更准确的示例命令,只排除了 /path/to/source 目录中的 dir1 和 dir2 目录: rclone sync /path/to/source remote:destination --exclude dir1/ --exclude dir2/ 一本正经地胡说八道!