From 5a6bdc991ae7d745f2f3db45593e66bbc27e0339 Mon Sep 17 00:00:00 2001 From: Ivan Groenewold <9805809+igroene@users.noreply.github.com> Date: Wed, 3 Dec 2025 07:52:35 -0300 Subject: [PATCH 1/5] Update oplog-replay.md Add info about using (epoch, ordinal) pair --- docs/usage/oplog-replay.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/usage/oplog-replay.md b/docs/usage/oplog-replay.md index 325b9fbd..13e814fe 100644 --- a/docs/usage/oplog-replay.md +++ b/docs/usage/oplog-replay.md @@ -33,6 +33,11 @@ After you [restored a physical backup](restore.md), do the following: ```bash pbm oplog-replay --start="2022-01-02T15:00:00" --end="2022-01-03T15:00:00" ``` + + !!! note "" + + Another possibility is using MongoDB’s (epoch, ordinal) values directly. + For example, it is possible to use `pbm oplog-replay --end “1764576382,0”` or `--end “1764576382,100”` so it’s possible to specify up to the exact operation you need to apply in the oplog. 4. After the oplog replay, make a fresh backup and enable the point-in-time recovery oplog slicing. From 2af4ed82fe8ef5e744607a9e4cee1afb0ad3b834 Mon Sep 17 00:00:00 2001 From: Ivan Groenewold <9805809+igroene@users.noreply.github.com> Date: Wed, 3 Dec 2025 10:43:42 -0300 Subject: [PATCH 2/5] Update docs/usage/oplog-replay.md Co-authored-by: Anastasia Alexandrova --- docs/usage/oplog-replay.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/oplog-replay.md b/docs/usage/oplog-replay.md index 13e814fe..5d54785f 100644 --- a/docs/usage/oplog-replay.md +++ b/docs/usage/oplog-replay.md @@ -36,7 +36,7 @@ After you [restored a physical backup](restore.md), do the following: !!! note "" - Another possibility is using MongoDB’s (epoch, ordinal) values directly. + Another possibility is to use MongoDB’s (epoch, ordinal) values directly. This enables you to replay oplog up to a specific operation. For example, it is possible to use `pbm oplog-replay --end “1764576382,0”` or `--end “1764576382,100”` so it’s possible to specify up to the exact operation you need to apply in the oplog. 4. After the oplog replay, make a fresh backup and enable the point-in-time recovery oplog slicing. From 56b9446e44ff9ed2b6b3dff2178171ff4b840e32 Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Wed, 3 Dec 2025 17:06:29 +0100 Subject: [PATCH 3/5] Added a section with the explanatio n how to define time for oplog replay and how PBM processes ops --- docs/usage/oplog-replay.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/usage/oplog-replay.md b/docs/usage/oplog-replay.md index 5d54785f..5a334e2d 100644 --- a/docs/usage/oplog-replay.md +++ b/docs/usage/oplog-replay.md @@ -13,13 +13,25 @@ By replaying these oplog slices on top of the backup snapshot with the [`pbm opl Use the oplog replay functionality with caution, only when you are sure about the starting time from which to replay oplog. The oplog replay does not guarantee data consistency when restoring from any backup. However, it is less error-prone for backups made with Percona Backup for MongoDB. +## Ways to specify time for oplog replay + +PBM uses MongoDB's timestamp format for oplog replay, which provides operation-level resolution. Each oplog operation is identified by `(epoch, ordinal)`, where `epoch` is the Unix time in seconds and `ordinal` distinguishes multiple operations within the same second. The specified operation is always included in the replay. + +You can define the oplog replay stop point in two ways: + +1. **By ISO timestamp**: + Specify an end time as an ISO timestamp (for example, `2025-01-02T15:00:00`). PBM converts this to `(epoch, 0)` and includes that operation. Use this method for convenience when the first operation within a specific second is sufficient. + +2. **By MongoDB timestamp tuple**: + Specify the stop point as `epoch,ordinal` (e.g., `1764576382,20`). PBM includes all operations up to that exact operation. Use this method when you need precise control over which specific operations within a second to include. This is especially useful when multiple operations occurred at the same time. + ## Oplog replay for physical backups !!! note "" Starting with version 2.2.0, oplog replay on top of a physical backups made with Percona Backup for MongoDB is done automatically as part of [point-in-time recovery](pitr-physical.md). -This section describes how to manually replay oplog on top of physical backups with Percona Backup for MongoDB version 2.1.0 and earlier. +This section describes how to **manually** replay oplog on top of physical backups made with Percona Backup for MongoDB version 2.1.0 and earlier. After you [restored a physical backup](restore.md), do the following: @@ -27,17 +39,21 @@ After you [restored a physical backup](restore.md), do the following: 2. Run `pbm status` or `pbm list` commands to find oplog chunks available for replay. +3. Run the `pbm oplog-replay` command and specify the `--start` and `--end` flags. See [how you can specify the time](#ways-to-specify-time-for-oplog-replay). -3. Run the `pbm oplog-replay` command and specify the `--start` and `--end` flags with the timestamps. + === "Use timestamp" - ```bash - pbm oplog-replay --start="2022-01-02T15:00:00" --end="2022-01-03T15:00:00" - ``` + ```bash + pbm oplog-replay --start="{{year}}-01-02T15:00:00" --end="{{year}}-01-03T15:00:00" + ``` - !!! note "" + === "Use `epoch,ordinal`" + + For a fine-grained precision which exactly operations within a second to include, specify the values for the `--start` and `--end` flags as `epoch,ordinal` tuples. - Another possibility is to use MongoDB’s (epoch, ordinal) values directly. This enables you to replay oplog up to a specific operation. - For example, it is possible to use `pbm oplog-replay --end “1764576382,0”` or `--end “1764576382,100”` so it’s possible to specify up to the exact operation you need to apply in the oplog. + ```bash + pbm oplog-replay --end “1764576382,100” + ``` 4. After the oplog replay, make a fresh backup and enable the point-in-time recovery oplog slicing. From 41197f9ede58287840208fc3e47d0cf4bd6d683e Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Wed, 3 Dec 2025 18:02:46 +0100 Subject: [PATCH 4/5] Updated after the review --- docs/usage/oplog-replay.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage/oplog-replay.md b/docs/usage/oplog-replay.md index 5a334e2d..768da904 100644 --- a/docs/usage/oplog-replay.md +++ b/docs/usage/oplog-replay.md @@ -20,10 +20,10 @@ PBM uses MongoDB's timestamp format for oplog replay, which provides operation-l You can define the oplog replay stop point in two ways: 1. **By ISO timestamp**: - Specify an end time as an ISO timestamp (for example, `2025-01-02T15:00:00`). PBM converts this to `(epoch, 0)` and includes that operation. Use this method for convenience when the first operation within a specific second is sufficient. + Specify an end time as an ISO timestamp (for example, `2025-01-02T15:00:00`). PBM converts this to `(epoch, 0)` and includes all oplog operations within that second. Use this method when you want to include all operations that occurred until the specified second. 2. **By MongoDB timestamp tuple**: - Specify the stop point as `epoch,ordinal` (e.g., `1764576382,20`). PBM includes all operations up to that exact operation. Use this method when you need precise control over which specific operations within a second to include. This is especially useful when multiple operations occurred at the same time. + Specify the stop point as `epoch,ordinal` (e.g., `1764576382,20`). PBM includes all operations up to that exact operation. Use this method when you need precise control over which specific operations within a second to include. ## Oplog replay for physical backups From c65dedcf05acd854046dec81c046ce988d94b1c0 Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Wed, 3 Dec 2025 20:05:46 +0100 Subject: [PATCH 5/5] Removed confusing sentence --- docs/usage/oplog-replay.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/oplog-replay.md b/docs/usage/oplog-replay.md index 768da904..a06141e5 100644 --- a/docs/usage/oplog-replay.md +++ b/docs/usage/oplog-replay.md @@ -20,7 +20,7 @@ PBM uses MongoDB's timestamp format for oplog replay, which provides operation-l You can define the oplog replay stop point in two ways: 1. **By ISO timestamp**: - Specify an end time as an ISO timestamp (for example, `2025-01-02T15:00:00`). PBM converts this to `(epoch, 0)` and includes all oplog operations within that second. Use this method when you want to include all operations that occurred until the specified second. + Specify an end time as an ISO timestamp (for example, `2025-01-02T15:00:00`). Use this method when you want to include all operations that occurred until the specified second. 2. **By MongoDB timestamp tuple**: Specify the stop point as `epoch,ordinal` (e.g., `1764576382,20`). PBM includes all operations up to that exact operation. Use this method when you need precise control over which specific operations within a second to include.