From 2328d4e3713915404b47c0fc2431b5e8e72ce417 Mon Sep 17 00:00:00 2001 From: timfeirg Date: Fri, 24 Jan 2025 10:28:43 +0800 Subject: [PATCH 1/2] docs: fix sync description --- docs/en/guide/sync.md | 10 +++------- docs/zh_cn/guide/sync.md | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/en/guide/sync.md b/docs/en/guide/sync.md index 49c265f0da2e..0ba8e15a72b0 100644 --- a/docs/en/guide/sync.md +++ b/docs/en/guide/sync.md @@ -25,15 +25,15 @@ juicefs sync s3://mybucket.s3.us-east-2.amazonaws.com/ jfs://VOL_NAME/ juicefs sync --match-full-path --include='**.gz' --exclude='*' s3://xxx jfs://VOL_NAME/ # Copy all files that do not end with .gz -juicefs sync --match-full-path --exclude='**.gz' --include='*' s3://xxx/ jfs://VOL_NAME/ +juicefs sync --match-full-path --exclude='**.gz' s3://xxx/ jfs://VOL_NAME/ # Copy all files except the subdirectory named tempdir -juicefs sync --match-full-path --include='*' --exclude='**/tmpdir/**' s3://xxx/ jfs://VOL_NAME/ +juicefs sync --match-full-path --include='*' s3://xxx/ jfs://VOL_NAME/ ``` ## Pattern matching {#pattern-matching} -You can use `--exclude` and `--include` for filtering. If no filtering rules are provided, all files are scanned and copied. However, if you do need filtering, you must use both `--include` and `--exclude` for any of them to work properly (see examples above for reference). +You can use `--exclude` and `--include` for filtering. If no filtering rules are provided, all files are scanned and copied (`--include='*'` is the default). However, if you were to use `--include` filter to only handle files with the specified pattern, then you must also use `--exclude` as well, see examples above for reference. :::tip When using multiple matching patterns, it may be difficult to determine whether a file will be synchronized due to the filtering logic. In such cases, it is recommended to add the `--dry --debug` option to preview the files selected for synchronization. If the results are not as expected, adjust the matching patterns accordingly. @@ -57,10 +57,6 @@ In addition: Here are some examples of matching patterns: -:::tip -`--include` and `--exclude` must **be used together**. If you only specify `--include` without any `--exclude`, filtering will not work (and vice versa). Therefore, if you want to copy a command from examples below, ensure you append `--include='*'` to make them effective. -::: - + `--exclude='*.o'` excludes all files matching `*.o`. + `--exclude='/foo/*/bar'` excludes `bar` files located two levels under `/foo`, such as `/foo/spam/bar`, but not `/foo/spam/eggs/bar`. + `--exclude='/foo/**/bar'` excludes `bar` files at any level under `/foo`. diff --git a/docs/zh_cn/guide/sync.md b/docs/zh_cn/guide/sync.md index 85c0ed8266a9..1c892353d20e 100644 --- a/docs/zh_cn/guide/sync.md +++ b/docs/zh_cn/guide/sync.md @@ -22,15 +22,15 @@ juicefs sync oss://mybucket.oss-cn-shanghai.aliyuncs.com s3://mybucket.s3.us-eas juicefs sync --match-full-path --include='**.gz' --exclude='*' s3://xxx s3://xxx # 拷贝不以 .gz 结尾的所有文件 -juicefs sync --match-full-path --exclude='**.gz' --include='*' s3://xxx/ s3://xxx +juicefs sync --match-full-path --exclude='**.gz' s3://xxx/ s3://xxx # 拷贝所有文件,但忽略名为 tmpdir 的子目录 -juicefs sync --match-full-path --include='*' --exclude='**/tmpdir/**' s3://xxx/ s3://xxx +juicefs sync --match-full-path --exclude='**/tmpdir/**' s3://xxx/ s3://xxx ``` ## 模式匹配 {#pattern-matching} -你可以通过 `--exclude` 和 `--include` 来包含或排除要同步的文件路径。如果不提供任何规则,默认会同步所有扫描到的文件。但如果需要过滤特定文件,则**必须同时使用`--include` 和 `--exclude`**,不可以单独只使用其一,具体请参考上方的示范命令。 +你可以通过 `--exclude` 和 `--include` 来包含或排除要同步的文件路径。如果不提供任何规则,默认会同步所有扫描到的文件(默认就是 `--include='*'`)。但如果需要使用 `--include` 实现只包含特定命名模式的文件,则**必须同时使用 `--exclude` 来排除其他文件**,具体请参考上方的示范命令。 :::tip 当提供多个匹配模式时,取决于你具体使用的「过滤模式」,对于判断是否要同步某个文件可能会变得很困难。此时建议加上 `--dry --debug` 选项提前查看要同步的具体文件是否符合预期,如果不符合预期则需要调整匹配模式。 @@ -54,10 +54,6 @@ juicefs sync --match-full-path --include='*' --exclude='**/tmpdir/**' s3://xxx/ 以下是一些匹配模式的例子: -:::tip -`--include` 和 `--exclude` 必须**同时使用**,不能只用 `--include` 而没有 `--exclude`,反之亦然。因此如果要仿照下方示范撰写命令,还需要额外追加 `--include='*'` 才能发挥作用。 -::: - + `--exclude '*.o'` 将排除所有文件名能匹配 `*.o` 的文件; + `--exclude '/foo/*/bar'` 将排除根目录中名为 `foo` 的目录向下「两层」的目录中名为 `bar` 的文件; + `--exclude '/foo/**/bar'` 将排除根目录中名为 `foo` 的目录向下「任意层级」的目录中名为 `bar` 的文件。 From 911acf18958dec058b51c10ab9b7a6e5366a4d80 Mon Sep 17 00:00:00 2001 From: timfeirg Date: Sun, 26 Jan 2025 10:20:48 +0800 Subject: [PATCH 2/2] Update docs/en/guide/sync.md Co-authored-by: Caitin <34535727+CaitinChen@users.noreply.github.com> --- docs/en/guide/sync.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/guide/sync.md b/docs/en/guide/sync.md index 0ba8e15a72b0..03a47b67d2e8 100644 --- a/docs/en/guide/sync.md +++ b/docs/en/guide/sync.md @@ -33,7 +33,7 @@ juicefs sync --match-full-path --include='*' s3://xxx/ jfs://VOL_NAME/ ## Pattern matching {#pattern-matching} -You can use `--exclude` and `--include` for filtering. If no filtering rules are provided, all files are scanned and copied (`--include='*'` is the default). However, if you were to use `--include` filter to only handle files with the specified pattern, then you must also use `--exclude` as well, see examples above for reference. +You can use `--exclude` and `--include` for filtering. If no filtering rules are provided, all files are scanned and copied (`--include='*'` is the default). However, if you use the `--include` filter to match files with a specific pattern, you must also use `--exclude` to exclude other files. See the examples above for reference. :::tip When using multiple matching patterns, it may be difficult to determine whether a file will be synchronized due to the filtering logic. In such cases, it is recommended to add the `--dry --debug` option to preview the files selected for synchronization. If the results are not as expected, adjust the matching patterns accordingly.