Xavier
Xavier
Published on 2025-02-18 / 7 Visits
0
0

Copy MinIO bucket

To copy a MinIO bucket to a specified local directory for backup, you can use the MinIO Client (mc) tool. Here’s a step-by-step guide:

Step 1: Install MinIO Client (mc)

If you haven’t installed mc yet, you can download and install it using the following commands:

bashCopy

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/

Step 2: Configure MinIO Client

Configure mc to connect to your MinIO server. Replace myminio, http://your-minio-server:9000, ACCESS_KEY, and SECRET_KEY with your actual alias, MinIO server URL, access key, and secret key.

bashCopy

mc alias set myminio http://your-minio-server:9000 ACCESS_KEY SECRET_KEY

Step 3: Copy the Bucket to a Local Directory

Use the mc mirror command to copy the entire bucket to a specified local directory. This command will recursively copy all objects in the bucket to the local directory.

bashCopy

mc mirror myminio/my-bucket /path/to/local/directory
  • myminio/my-bucket is the MinIO bucket you want to copy.

  • /path/to/local/directory is the local directory where you want to save the backup.

Step 4: Verify the Backup

After the command completes, you can verify that the files have been copied to the specified local directory.

Additional Tips

  • Incremental Backup: If you want to perform incremental backups (only copying new or modified files), you can use the --watch option:

    bashCopy

    mc mirror --watch myminio/my-bucket /path/to/local/directory

    This will monitor the source bucket and update the local directory with any changes.

  • Remove Extra Files: To ensure that the local directory matches the source bucket exactly (removing any files in the local directory that are not in the source bucket), use the --remove option:

    bashCopy

    mc mirror --remove myminio/my-bucket /path/to/local/directory

    This will delete any files in the local directory that do not exist in the source bucket.

By following these steps, you can easily back up a MinIO bucket to a local directory using the MinIO Client tool.


Comment