Add scripts for MinIO client installation and S3 object copying

- Created 01-install.sh to download and set up the MinIO client.
- Created 02-copy.sh to configure MinIO aliases and mirror objects between buckets.
- Added copy.ts to implement S3 object copying functionality using AWS SDK.
This commit is contained in:
2026-02-06 19:11:02 +08:00
commit b6d8af60a1
8 changed files with 1350 additions and 0 deletions

0
.env.example Normal file
View File

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
node_modules
.env
!.env*example
dist
coverage
.DS_Store

3
AGENTS.md Normal file
View File

@@ -0,0 +1,3 @@
# 目标是迁移minio的数据到其他的对象存储当中
## 配置环境变量

18
package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "@kevisual/s3-migrate",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"packageManager": "pnpm@10.24.0",
"dependencies": {
"@aws-sdk/client-s3": "^3.984.0",
"@types/node": "^25.2.1",
"dotenv": "^17.2.4"
}
}

1278
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

6
scripts/01-install.sh Normal file
View File

@@ -0,0 +1,6 @@
curl https://dl.min.io/client/mc/release/linux-amd64/mc \
--create-dirs \
-o $HOME/minio-binaries/mc
chmod +x $HOME/minio-binaries/mc
export PATH=$PATH:$HOME/minio-binaries/

13
scripts/02-copy.sh Normal file
View File

@@ -0,0 +1,13 @@
mc alias set minio http://localhost:9000 ${O_S3_ACCESS_KEY_ID} ${O_S3_SECRET_ACCESS_KEY}
mc alias set tos https://tos-s3-cn-shanghai.ivolces.com ${S3_ACCESS_KEY_ID} ${S3_SECRET_ACCESS_KEY}
mc alias set tos https://tos-cn-shanghai.volces.com ${S3_ACCESS_KEY_ID} ${S3_SECRET_ACCESS_KEY}
# 查看tos桶内对象只做验证用
# mc ls tos/envision
# 桶间同步
mc mirror minio/resources tos/envision --parallel 10
# 查看minio桶内对象只做验证用
# mc ls minio/resources

26
src/copy.ts Normal file
View File

@@ -0,0 +1,26 @@
import { S3Client, ListObjectsV2Command, GetBucketMetadataConfigurationCommand, HeadObjectCommand, CopyObjectCommand } from '@aws-sdk/client-s3';
import dotenv from 'dotenv';
dotenv.config();
const oldS3Client = new S3Client({
region: process.env.O_S3_REGION!,
endpoint: process.env.O_S3_ENDPOINT,
credentials: {
accessKeyId: process.env.O_S3_ACCESS_KEY_ID!,
secretAccessKey: process.env.O_S3_SECRET_ACCESS_KEY!,
},
forcePathStyle: true,
});
const newS3Client = new S3Client({
region: process.env.S3_REGION!,
endpoint: process.env.S3_ENDPOINT,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID!,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
},
});
const copyS3Object = async () => {
//
}