|
1 | 1 | # s3utils |
2 | 2 | S3 Connector and Zenko Utilities |
3 | 3 |
|
4 | | -Run the docker container as |
| 4 | +Run the Docker container as |
5 | 5 | ``` |
6 | | -docker run --net=host -e 'ACCESS_KEY=accessKey' -e 'SECRET_KEY=secretkey' -e 'ENDPOINT=http://127.0.0.1:8000' zenko/s3utils node scriptName bucket1[,bucket2...] |
| 6 | +docker run --net=host -e 'ACCESS_KEY=accessKey' -e 'SECRET_KEY=secretKey' -e 'ENDPOINT=http://127.0.0.1:8000' zenko/s3utils node scriptName bucket1[,bucket2...] |
7 | 7 | ``` |
8 | 8 |
|
9 | | -Optionally, the environment variable "WORKERS" may be set to specify |
10 | | -how many parallel workers should run, otherwise a default of 10 |
11 | | -workers will be used. |
| 9 | +## Trigger CRR on existing objects |
12 | 10 |
|
13 | | -## Trigger CRR on objects that were put before replication was enabled on the bucket |
14 | | - |
15 | | -1. Enable versioning and setup replication on the bucket |
| 11 | +1. Enable versioning and set up replication on the bucket. |
16 | 12 | 2. Run script as |
17 | 13 | ``` |
18 | 14 | node crrExistingObjects.js testbucket1,testbucket2 |
19 | 15 | ``` |
20 | 16 |
|
21 | | -## Trigger CRR on *all* objects of a bucket |
| 17 | +### Extra environment variables |
| 18 | + |
| 19 | +Additionally, the following extra environment variables can be passed |
| 20 | +to the script to modify its behavior: |
| 21 | + |
| 22 | +#### TARGET_REPLICATION_STATUS |
| 23 | + |
| 24 | +Comma-separated list of replication statuses to target for CRR |
| 25 | +requeueing. The recognized statuses are: |
| 26 | + |
| 27 | +* **NEW**: No replication status is attached to the object. This is |
| 28 | + the state of objects written without any CRR policy attached to |
| 29 | + the bucket that would have triggered CRR on them. |
| 30 | + |
| 31 | +* **PENDING**: The object replication status is PENDING. |
| 32 | + |
| 33 | +* **COMPLETED**: The object replication status is COMPLETED. |
| 34 | + |
| 35 | +* **FAILED**: The object replication status is FAILED. |
| 36 | + |
| 37 | +* **REPLICA**: The object replication status is REPLICA (objects that |
| 38 | + were put to a target site via CRR have this status). |
| 39 | + |
| 40 | +The default script behavior is to affect objects that have no |
| 41 | +replication status attached (so equivalent to |
| 42 | +`TARGET_REPLICATION_STATUS=NEW`). |
| 43 | + |
| 44 | +Examples: |
| 45 | + |
| 46 | +`TARGET_REPLICATION_STATUS=PENDING,COMPLETED` |
| 47 | + |
| 48 | +Requeue objects that either have a replication status of PENDING or |
| 49 | +COMPLETED for CRR, do not requeue the others. |
| 50 | + |
| 51 | +`TARGET_REPLICATION_STATUS=NEW,PENDING,COMPLETED,FAILED` |
| 52 | + |
| 53 | +Trigger CRR on all original source objects (not replicas) in a bucket. |
| 54 | + |
| 55 | +`TARGET_REPLICATION_STATUS=REPLICA` |
| 56 | + |
| 57 | +For disaster recovery notably, it may be useful to reprocess REPLICA |
| 58 | +objects to re-sync a backup bucket to the primary site. |
| 59 | + |
| 60 | +#### WORKERS |
| 61 | + |
| 62 | +Specify how many parallel workers should run to update object |
| 63 | +metadata. The default is 10 parallel workers. |
| 64 | + |
| 65 | +Example: |
| 66 | + |
| 67 | +`WORKERS=50` |
| 68 | + |
| 69 | +#### MAX_UPDATES |
| 70 | + |
| 71 | +Specify a maximum number of metadata updates to execute before |
| 72 | +stopping the script. |
| 73 | + |
| 74 | +If the script reaches this limit, it outputs a log line containing |
| 75 | +the KeyMarker and VersionIdMarker to pass to the next invocation (as |
| 76 | +environment variables `KEY_MARKER` and `VERSION_ID_MARKER`) and the |
| 77 | +updated bucket list without the already completed buckets. At the next |
| 78 | +invocation of the script, those two environment variables must be |
| 79 | +set and the updated bucket list passed on the command line to resume |
| 80 | +where the script stopped. |
| 81 | + |
| 82 | +The default is unlimited (will process the complete listing of buckets |
| 83 | +passed on the command line). |
| 84 | + |
| 85 | +**If the script queues too many objects and Backbeat cannot |
| 86 | + process them quickly enough, Kafka may drop the oldest entries**, |
| 87 | + and the associated objects will stay in the **PENDING** state |
| 88 | + permanently without being replicated. When the number of objects |
| 89 | + is large, it is a good idea to limit the batch size and wait |
| 90 | + for CRR to complete between invocations. |
| 91 | + |
| 92 | +Example: |
| 93 | + |
| 94 | +`MAX_UPDATES=10000` |
| 95 | + |
| 96 | +This limits the number of updates to 10,000 objects, which requeues |
| 97 | +a maximum of 10,000 objects to replicate before the script stops. |
| 98 | + |
| 99 | +#### KEY_MARKER |
| 100 | + |
| 101 | +Set to resume from where an earlier invocation stopped (see |
| 102 | +[MAX_UPDATES](#MAX_UPDATES)). |
| 103 | + |
| 104 | +Example: |
22 | 105 |
|
23 | | -This mode includes the objects that have already been replicated or |
24 | | -that have a replication status attached. |
| 106 | +`KEY_MARKER="some/key"` |
25 | 107 |
|
26 | | -For disaster recovery notably, to re-sync a backup bucket to the |
27 | | -primary site, it may be useful to reprocess all objects regardless of |
28 | | -the existence of a current replication status (e.g. "REPLICA"). |
| 108 | +#### VERSION_ID_MARKER |
29 | 109 |
|
30 | | -Follow the above steps for using "crrExistingObjects" script, and |
31 | | -specify an extra environment variable `-e "PROCESS_ALL=true"` to force |
32 | | -the script to reset the replication status of all objects in the |
33 | | -bucket to "pending", which will force a replication for all objects. |
| 110 | +Set to resume from where an earlier invocation stopped (see |
| 111 | +[MAX_UPDATES](#MAX_UPDATES)). |
| 112 | + |
| 113 | +Example: |
| 114 | + |
| 115 | +`VERSION_ID_MARKER="123456789"` |
| 116 | + |
| 117 | + |
| 118 | +### Example use cases |
| 119 | + |
| 120 | +#### CRR existing objects after setting a replication policy for the first time |
| 121 | + |
| 122 | +For this use case, it's not necessary to pass any extra environment |
| 123 | +variable, because the default behavior is to process objects without a |
| 124 | +replication status attached. |
| 125 | + |
| 126 | +To avoid requeuing too many entries at once, pass this value: |
| 127 | + |
| 128 | +``` |
| 129 | +export MAX_UPDATES=10000 |
| 130 | +``` |
| 131 | + |
| 132 | +#### Re-queue objects stuck in PENDING state |
| 133 | + |
| 134 | +If Kafka has dropped replication entries, leaving objects stuck in a |
| 135 | +PENDING state without being replicated, pass the following extra |
| 136 | +environment variables to reprocess them: |
| 137 | + |
| 138 | +``` |
| 139 | +export TARGET_REPLICATION_STATUS=PENDING |
| 140 | +export MAX_UPDATES=10000 |
| 141 | +``` |
| 142 | + |
| 143 | +**Warning**: This may cause replication of objects already in the |
| 144 | +Kafka queue to repeat. To avoid this, set the backbeat consumer |
| 145 | +offsets of "backbeat-replication" Kafka topic to the latest topic |
| 146 | +offsets before launching the script, to skip over the existing |
| 147 | +consumer log. |
| 148 | + |
| 149 | +#### Replicate entries that failed a previous replication |
| 150 | + |
| 151 | +If entries have permanently failed to replicate with a FAILED |
| 152 | +replication status and were lost in the failed CRR API, it's still |
| 153 | +possible to re-attempt replication later with the following |
| 154 | +extra environment variables: |
| 155 | + |
| 156 | +``` |
| 157 | +export TARGET_REPLICATION_STATUS=FAILED |
| 158 | +export MAX_UPDATES=10000 |
| 159 | +``` |
| 160 | + |
| 161 | +#### Re-sync a primary site completely to a new DR site |
| 162 | + |
| 163 | +To re-sync objects to a new DR site (for example, when the original |
| 164 | +DR site is lost) force a new replication of all original objects |
| 165 | +with the following environment variables (after setting the proper |
| 166 | +replication configuration to the DR site bucket): |
| 167 | + |
| 168 | +``` |
| 169 | +export TARGET_REPLICATION_STATUS=NEW,PENDING,COMPLETED,FAILED |
| 170 | +export MAX_UPDATES=10000 |
| 171 | +``` |
| 172 | + |
| 173 | +#### Re-sync a DR site back to the primary site |
| 174 | + |
| 175 | +When objects have been lost from the primary site you can re-sync |
| 176 | +objects from the DR site to the primary site by re-syncing the |
| 177 | +objects that have a REPLICA status with the following environment |
| 178 | +variables (after setting the proper replication configuration |
| 179 | +from the DR bucket to the primary bucket): |
| 180 | + |
| 181 | +``` |
| 182 | +export TARGET_REPLICATION_STATUS=REPLICA |
| 183 | +export MAX_UPDATES=10000 |
| 184 | +``` |
34 | 185 |
|
35 | 186 | # Empty a versioned bucket |
36 | 187 |
|
37 | | -This script deletes all versions of objects in the bucket including delete markers, |
| 188 | +This script deletes all versions of objects in the bucket, including delete markers, |
38 | 189 | and aborts any ongoing multipart uploads to prepare the bucket for deletion. |
39 | 190 |
|
40 | | -**Note: This will delete data associated with the objects and it's not recoverable** |
| 191 | +**Note: This deletes the data associated with objects and is not recoverable** |
41 | 192 | ``` |
42 | 193 | node cleanupBuckets.js testbucket1,testbucket2 |
43 | 194 | ``` |
44 | 195 |
|
45 | 196 | # List objects that failed replication |
46 | 197 |
|
47 | | -This script can print the list of objects that failed replication to stdout by |
48 | | -taking a comma-separated list of buckets. Run the command as |
| 198 | +This script prints the list of objects that failed replication to stdout, |
| 199 | +following a comma-separated list of buckets. Run the command as |
49 | 200 |
|
50 | 201 | ```` |
51 | 202 | node listFailedObjects testbucket1,testbucket2 |
|
0 commit comments