Purpose: This script is specifically designed for reconstructing Oracle Data Pump export files that were written to Object Storage using Swift format. It combines segmented files from a source bucket (accessed via PAR) into their original format suitable for import using Oracle Data Pump (impdp). This script can be repurposed for similar format file transfers or other segmented file formats.
- OCI Cloud Shell or equivalent Bash shell environment with configured OCI CLI
- Proper IAM permissions to:
- Read from source bucket (via PAR)
- Write to target bucket
curl
utility installed
- Source bucket: Valid Pre-Authenticated Request (PAR) with read access to all segment objects
- Target bucket: Write permissions for the authenticated OCI CLI user
SOURCE_URL
: PAR URL of source bucket (no trailing slash)TARGET_BUCKET
: Name of the destination bucket<index>
: Index identifier to use when referencing individual segment (Example: "01")
- Source segment and its chunks format (OCI Swift format):
export<index>.dmp_segments/aaaaaa
,export<index>.dmp_segments/aaaaab
, etc. - Target file format:
export<index>.dmp
-
Update the script with your specific values:
TARGET_BUCKET="<Target bucket name>" SOURCE_URL="<Source PAR url including bucket name with no trailing slash>"
-
Run the script with an index parameter:
./script.sh 01
-
Segment Discovery
- Starts with segment "aaaaaa"
- Performs HEAD requests to detect available segments
- Collects metadata including file sizes
- Progress reported every 100 segments
-
File Transfer
- Downloads each segment sequentially
- Includes retry logic (3 attempts with 2-second delay)
- Streams concatenated segments directly to target bucket
- No intermediate file storage required
-
Completion
- Reports total segments processed
- Shows total size transferred
- Indicates success or failure status
- Validates command-line arguments
- Checks HTTP response codes
- Verifies segment sizes
- Reports transfer status
- Exits with appropriate status codes on failures
- Streaming transfer minimizes (basically eliminates) disk usage which is important in OCI Cloud Shell environment
- Network retry logic for resilience
- Progress monitoring with timestamps
- Memory-efficient segment tracking
- Assumes sequential segment naming (aaaaaa, aaaaab, etc.)
- Requires valid PAR URL with proper access
- TARGET_BUCKET must exist before script execution and the user must have access to write into it via
oci
CLI
$ ./script.sh 01
Collecting segments...
Checking segment: aaaaaa
2024-02-20 10:15:30 Milestone: 100 segments found, Total size: 1048576000 bytes
...
Transfer completed successfully.
Total segments: 150
Total size: 1572864000 bytes
MIT License
Copyright (c) 2025 [Alexey Novikov]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.