Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix sync description #5605

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions docs/en/guide/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
timfeirg marked this conversation as resolved.
Show resolved Hide resolved

:::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.
Expand All @@ -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`.
Expand Down
10 changes: 3 additions & 7 deletions docs/zh_cn/guide/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 选项提前查看要同步的具体文件是否符合预期,如果不符合预期则需要调整匹配模式。
Expand All @@ -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` 的文件。
Expand Down
Loading