Skip to content
rustfsPublic

About

Migration buckets between different S3 instance.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

RustFS Migration

English | Français | Italiano | Deutsch | Español | 简体中文 | 日本語 | 한국어

migration is a safe, one-way migration CLI for S3-compatible object storage clusters (such as RustFS and MinIO). It copies current objects from a source cluster (old) to a destination cluster (new) using path-style addressing, local SQLite checkpoints, and full-body verification.

Built around four strict safety guarantees:

  • Never overwrites: Every commit to the destination sends an atomic If-None-Match: * header on both PutObject and CompleteMultipartUpload. If a key already exists on the destination, both object bodies and preserved metadata are compared via SHA-256—matching objects are marked done, while divergent objects are logged to conflict.log and left untouched.
  • Never deletes: The tool never invokes DeleteObject or CopyObject. Failed multipart uploads only abort their own in-flight upload session (AbortMultipartUpload).
  • Resumable across interruptions: Inventory and per-object states persist in a local SQLite database (WAL mode with an exclusive writer lock). Press Ctrl+C to stop gracefully and resume later without re-uploading completed objects.
  • Full-body SHA-256 verification: Newly written objects are read back from the destination and checked byte-for-byte against the source SHA-256 digest and preserved metadata, rather than trusting cross-cluster ETags.

Important

Freeze source writes and deletes externally before scanning, and keep them frozen through final diff verification and cutover—including application deletes and bucket lifecycle expiration. Pause or tombstone-coordinate business deletes of inventory keys on the destination as well. --source-frozen (or source_frozen: true) is an operator confirmation, not a remote lock on S3. Ensure your destination server version genuinely honors atomic If-None-Match: * before running in production.

Documentation

Installation

Download prebuilt packages from GitHub Releases or CI/CD Artifacts and verify their .sha256 checksums before installing:

  • Debian / Ubuntu (.deb): rustfs-migration_0.2.0_amd64.deb / rustfs-migration_0.2.0_arm64.deb
    sha256sum -c rustfs-migration_0.2.0_amd64.deb.sha256
    sudo dpkg -i rustfs-migration_0.2.0_amd64.deb
  • RHEL / Rocky / AlmaLinux / CentOS (.rpm): rustfs-migration-0.2.0-1.x86_64.rpm / rustfs-migration-0.2.0-1.aarch64.rpm
    sha256sum -c rustfs-migration-0.2.0-1.x86_64.rpm.sha256
    sudo rpm -Uvh rustfs-migration-0.2.0-1.x86_64.rpm
  • Linux standalone binary / .tar.gz: migration-linux-amd64(.tar.gz) / migration-linux-arm64(.tar.gz)
  • Windows (amd64): migration-windows-amd64.zip / migration-windows-amd64.exe
  • Build from source (Go 1.26+, pure-Go SQLite, no CGO required):
    git clone https://github.com/rustfs/migration.git
    cd migration
    CGO_ENABLED=0 go build -trimpath -o bin/migration .

.deb and .rpm packages install /usr/bin/migration and a sample config at /etc/rustfs-migration/config.example.yaml.

Quick Start

# 1. Create an isolated working directory and secure your config file
mkdir -p ./jobs/cutover-01/spool
cp config.example.yaml ./jobs/cutover-01/config.yaml
chmod 600 ./jobs/cutover-01/config.yaml
# Edit ./jobs/cutover-01/config.yaml with your source/destination endpoints, keys, and state paths

# 2. Verify source connectivity (read-only)
migration list -c ./jobs/cutover-01/config.yaml

# 3. After freezing source writes & deletes externally, scan and copy objects
migration run -c ./jobs/cutover-01/config.yaml --source-frozen --workers 16 --rate-limit 30M

# 4. Inspect local SQLite progress counters (offline, no S3 calls)
migration status -c ./jobs/cutover-01/config.yaml

# 5. Verify full-body SHA-256 and metadata while both clusters remain quiescent
migration diff -c ./jobs/cutover-01/config.yaml --workers 32

Do not decommission the source cluster based solely on migration run exiting 0. Confirm FAILED=0 and PENDING=0 in status, review any CONFLICT or SKIPPED objects, and require a clean migration diff before cutover.

Configuration Overview

old:                                    # Source cluster (read-only)
  endpoint: "https://old.example.com"
  access_key: "OLD_AK"
  secret_key: "OLD_SK"
  region: "us-east-1"
  session_token: ""                     # Optional STS temporary token

new:                                    # Destination cluster (read/write, needs s3:CreateBucket if missing)
  endpoint: "https://new.example.com"
  access_key: "NEW_AK"
  secret_key: "NEW_SK"
  region: "us-east-1"
  session_token: ""

bucket: ""                              # Empty = all source buckets; set a name for single-bucket mode
source_frozen: false                    # Set true only after freezing writes/deletes externally
db_path: "./jobs/cutover-01/migration.db"
conflict_log: "./jobs/cutover-01/conflict.log"
spool_dir: "./jobs/cutover-01/spool"    # Defaults to db_path directory
spool_max_bytes: 1073741824             # 1 GiB concurrent temp-file budget

workers: 16                             # Concurrent objects (1..1024; 0/omitted = 16)
multipart_threshold: 52428800           # 50 MiB
multipart_part_size: 16777216           # 16 MiB (allowed: 5 MiB..5 GiB)
multipart_concurrency: 4                # Parallel parts per large object (1..64; product <= 4096)
rate_limit: 0                           # Aggregate source-read cap (e.g. 20M or 20MiB; 0 = unlimited)
  • Strict parsing: Unknown YAML keys and multi-document YAML files fail fast at startup. Endpoint URLs must be plain http:// or https:// URLs without embedded credentials, query strings, or # fragments.
  • Precedence: CLI flags > Environment variables > YAML > Built-in defaults.
  • Environment variables: OLD_ENDPOINT, OLD_AK, OLD_SK, OLD_REGION, OLD_SESSION_TOKEN, NEW_ENDPOINT, NEW_AK, NEW_SK, NEW_REGION, NEW_SESSION_TOKEN, REGION, BUCKET, DB_PATH, CONFLICT_LOG, SPOOL_DIR, WORKERS, MULTIPART_CONCURRENCY, RATE_LIMIT, SOURCE_FROZEN.

See the User Manual for detailed 0-value rules, unit conversions (20M decimal vs 20MiB binary), and disk/bandwidth sizing.

Commands

Command Description Writes to Target
migration list List all source buckets and creation timestamps (UTC) No
migration scan Single-threaded ListObjectsV2 inventory into local SQLite No
migration run Recommended: scan then copy pending/failed objects Yes (conditional, never overwrites)
migration migrate Copy pending/failed objects from an existing completed scan Yes (conditional, never overwrites)
migration status Print per-bucket counters from local SQLite (safe while running) No
migration diff Verify buckets, sizes, preserved metadata, and full-body SHA-256 No (reads both bodies; unthrottled)

Key flags:

  • --strict on run / migrate: fail if any object remains pending, failed, conflict, or skipped (including prior runs).
  • --extra on diff: also report keys that exist only on the destination (informational; does not fail alone).
  • --strict on diff: also fail when destination-only buckets or keys exist.
  • --issues-jsonl <new-path> on diff: stream every difference (bucket, key, kind, detail) to a new JSON Lines file without overwriting existing files.

Scope

  • Migrated: Current object content, Content-Type (normalized to application/octet-stream when absent), Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Expires, and x-amz-meta-* user metadata.
  • Not migrated: Version history, delete markers, object tags, ACLs, storage class, source SSE parameters, Object Lock / retention / legal hold, bucket policies, CORS, and lifecycle rules.

Testing

go test ./...
go test -race ./...
go vet ./...

# Optional real-service verification against two isolated local RustFS instances:
python3 scripts/audit-local-rustfs.py \
  --rustfs-binary /absolute/path/to/rustfs --expect-version 1.0.4

License

Licensed under the Apache License 2.0. Copyright 2024–2026 RustFS, Inc.

About

Migration buckets between different S3 instance.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages