### Install mc Source: https://github.com/minio/mc/blob/master/CONTRIBUTING.md Build and install the mc binary. This command should complete successfully before creating a pull request. ```bash make install ``` -------------------------------- ### Install mc from Source using Go Source: https://github.com/minio/mc/blob/master/README.md Installs the MinIO Client from source using Go. Requires Go version 1.22 or later and a working Golang environment. ```go go install github.com/minio/mc@latest ``` -------------------------------- ### Install mc using Homebrew on macOS Source: https://github.com/minio/mc/blob/master/README.md Installs the MinIO Client package using Homebrew on macOS and displays the help message. ```bash brew install minio/stable/mc mc --help ``` -------------------------------- ### Get All Configuration Source: https://context7.com/minio/mc/llms.txt Retrieve the entire MinIO server configuration in a human-readable format using `mc admin config get`. This is useful for understanding current settings. ```bash mc admin config get myminio ``` -------------------------------- ### Setup mc Github Repository Source: https://github.com/minio/mc/blob/master/CONTRIBUTING.md Clone the mc repository from GitHub, build it, and view help information. Ensure your GOPATH is set correctly. ```bash $ mkdir -p $GOPATH/src/github.com/minio $ cd $GOPATH/src/github.com/minio $ git clone https://github.com/$USER_ID/mc $ cd mc $ make $ ./mc --help ``` -------------------------------- ### Example: Set Google Cloud Storage Alias Source: https://github.com/minio/mc/blob/master/README.md Example of setting an alias for Google Cloud Storage. Obtain your AccessKeyID and SecretAccessKey from the Google Cloud documentation. ```bash mc alias set gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 ``` -------------------------------- ### Example: Set MinIO Cloud Storage Alias Source: https://github.com/minio/mc/blob/master/README.md Example of setting an alias for a MinIO cloud storage service. The server URL, access key, and secret key are typically found in the MinIO server startup banner. ```bash mc alias set minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 ``` -------------------------------- ### Example: Set Amazon S3 Cloud Storage Alias Source: https://github.com/minio/mc/blob/master/README.md Example of setting an alias for Amazon S3. Ensure you have your AWS credentials and follow the AWS IAM user policy recommendations for restricted access. ```bash mc alias set s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 ``` -------------------------------- ### Force Start Healing Source: https://context7.com/minio/mc/llms.txt Manually trigger a healing process, even if MinIO determines it's not strictly necessary, using `mc admin heal --force-start`. Use with caution. ```bash mc admin heal --force-start myminio/mybucket ``` -------------------------------- ### GitLab CI Configuration for MinIO Client Source: https://github.com/minio/mc/blob/master/README.md Example GitLab CI configuration to set up MinIO Client aliases and perform file copy operations. Ensure to set the entrypoint to an empty string for GitLab CI. ```yaml deploy: image: name: minio/mc entrypoint: [''] stage: deploy before_script: - mc alias set minio $MINIO_HOST $MINIO_ACCESS_KEY $MINIO_SECRET_KEY script: - mc cp ``` -------------------------------- ### mc admin info - Get Server Information Source: https://context7.com/minio/mc/llms.txt Display MinIO server information including cluster status, disk usage, and health metrics. ```APIDOC ## mc admin info - Get Server Information ### Description Display MinIO server information including cluster status, disk usage, and health metrics. ### Method `admin info` ### Endpoint `/minio/mc` ### Parameters #### Query Parameters - **--offline** (boolean) - Optional - Shows only offline nodes/drives. - **--json** (boolean) - Optional - Outputs information in JSON format. ### Request Example ```bash # Get server information mc admin info play/ # Show only offline nodes/drives mc admin info --offline play/ # Output in JSON format mc admin info play/ --json ``` ``` -------------------------------- ### Get Specific Configuration Key Source: https://context7.com/minio/mc/llms.txt Fetch the value of a particular configuration key, such as 'region', using `mc admin config get`. This allows for targeted inspection of settings. ```bash mc admin config get myminio region ``` -------------------------------- ### Add Dependencies with go mod Source: https://github.com/minio/mc/blob/master/CONTRIBUTING.md Manage project dependencies using go mod. Add new dependencies with `go get` and update the go.mod file with `go mod tidy`. ```bash go get foo/bar ``` ```bash GO111MODULE=on go mod tidy ``` -------------------------------- ### Mirror All Buckets Between Sites with Watch Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --remove --watch` to continuously synchronize all buckets between two sites, ensuring data consistency and removing any discrepancies. This is suitable for active-active replication setups. ```bash mc mirror --remove --watch site1-alias/ site2-alias/ ``` -------------------------------- ### Get Server Information Source: https://context7.com/minio/mc/llms.txt Retrieve detailed information about the MinIO server, including its status, disk usage, and health metrics, using `mc admin info`. This is essential for monitoring server health. ```bash mc admin info play/ ``` -------------------------------- ### mc Shell Autocompletion Source: https://github.com/minio/mc/blob/master/README.md Installs shell autocompletion for `mc` in bash, zsh, or fish shells. After installation and restarting the shell, you can use the TAB key to see available `mc` commands and options. ```bash mc --autocompletion ``` ```bash mc ``` -------------------------------- ### Run mc in Interactive Docker Container Source: https://github.com/minio/mc/blob/master/README.md Starts an interactive MinIO Client Docker container, allowing you to run mc commands directly within the container. Use 'mc alias' to configure access to other S3 services. ```bash docker run -it --entrypoint=/bin/sh minio/mc ``` -------------------------------- ### Get User Information Source: https://context7.com/minio/mc/llms.txt Fetch details about a specific user, including their status and associated policies, using `mc admin user info`. This is useful for troubleshooting user access issues. ```bash mc admin user info myminio newuser ``` -------------------------------- ### Start Healing on All Buckets Source: https://context7.com/minio/mc/llms.txt Initiate data healing operations across all buckets on the MinIO server using `mc admin heal`. This process ensures data integrity in erasure-coded deployments. ```bash mc admin heal myminio ``` -------------------------------- ### Get Policy Information Source: https://context7.com/minio/mc/llms.txt Retrieve the details of a specific IAM policy, including its rules and associated principals, using `mc admin policy info`. ```bash mc admin policy info myminio mypolicy ``` -------------------------------- ### Set Configuration Value Source: https://context7.com/minio/mc/llms.txt Modify a MinIO server configuration setting using `mc admin config set`. For example, to set the region name. ```bash mc admin config set myminio region name=us-west-1 ``` -------------------------------- ### Get Bucket Versioning Status Source: https://context7.com/minio/mc/llms.txt Check the current versioning status of a bucket using `mc version info`. This command returns whether versioning is enabled, suspended, or disabled. ```bash mc version info myminio/mybucket ``` -------------------------------- ### Read Object with Offset Source: https://context7.com/minio/mc/llms.txt Use `mc cat --offset` to read an object starting from a specific byte offset. This is useful for partial reads or resuming downloads. ```bash mc cat --offset 1024 play/my-bucket/my-object ``` -------------------------------- ### Download and Execute mc Binary on Linux Source: https://github.com/minio/mc/blob/master/README.md Downloads the 64-bit Intel Linux binary for MinIO Client, makes it executable, and displays the help message. ```bash wget https://dl.min.io/client/mc/release/linux-amd64/mc chmod +x mc ./mc --help ``` -------------------------------- ### Import Configuration Source: https://context7.com/minio/mc/llms.txt Apply a MinIO server configuration from a file using `mc admin config import`. Ensure the configuration file is correctly formatted. ```bash mc admin config import myminio < config.txt ``` -------------------------------- ### Add New User Source: https://context7.com/minio/mc/llms.txt Create a new user account on the MinIO server with a specified username and password using `mc admin user add`. Ensure strong passwords are used. ```bash mc admin user add myminio newuser newuser123 ``` -------------------------------- ### Execute mc.exe on Windows Source: https://github.com/minio/mc/blob/master/README.md Executes the MinIO Client binary for Windows and displays the help message. ```powershell mc.exe --help ``` -------------------------------- ### Configure Storage Service Aliases Source: https://context7.com/minio/mc/llms.txt Set up shorthand references to storage services with their authentication details. Aliases are stored in `~/.mc/config.json`. ```bash mc alias set myminio http://192.168.1.51:9000 minio minio123 ``` ```bash mc alias set mys3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api "s3v4" --path "off" ``` ```bash mc alias set gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 ``` ```bash mc alias list ``` ```bash mc alias remove myminio ``` -------------------------------- ### Copy All Versions to Local with Version Info Source: https://context7.com/minio/mc/llms.txt Use `mc find --versions --exec` to find all versions of objects and copy them to a local directory, including version information in the filename. This is crucial for backup and recovery scenarios. ```bash mc find s3/bucket --versions --exec "mc cp --version-id {version} {} /tmp/dir/{}.{version}" ``` -------------------------------- ### List Buckets using mc Source: https://github.com/minio/mc/blob/master/README.md Lists all buckets from a specified alias, such as 'play' for play.min.io. This command is useful for verifying connectivity and viewing available storage. ```bash mc ls play ``` -------------------------------- ### Format Code with go fmt Source: https://github.com/minio/mc/blob/master/CONTRIBUTING.md Ensure code adheres to Go style conventions by running the `go fmt` command. ```bash go fmt ``` -------------------------------- ### Import Lifecycle Configuration Source: https://context7.com/minio/mc/llms.txt Apply a lifecycle configuration from a JSON file to a bucket using `mc ilm rule import`. Ensure the JSON file adheres to the expected format. ```bash mc ilm rule import myminio/mybucket < lifecycle.json ``` -------------------------------- ### Create New Buckets Source: https://context7.com/minio/mc/llms.txt Create new buckets with optional region, versioning, and object locking configuration. Can also be used to create local directories similar to `mkdir -p`. ```bash mc mb s3/mynewbucket ``` ```bash mc mb --region=us-west-2 s3/myregionbucket ``` ```bash mc mb /tmp/this/new/dir1 ``` ```bash mc mb /mnt/sdb/mydisk /mnt/sdc/mydisk /mnt/sdd/mydisk ``` ```bash mc mb --ignore-existing myminio/mynewbucket ``` ```bash mc mb --with-lock --region=us-west-2 s3/myregionbucket ``` ```bash mc mb --with-versioning myminio/myversionedbucket ``` -------------------------------- ### Generate Download URL Source: https://context7.com/minio/mc/llms.txt Use `mc share download` to create a presigned URL for temporary object download. By default, the URL expires in 7 days. ```bash mc share download s3/backup/2006-Mar-1/backup.tar.gz ``` -------------------------------- ### Mirror with Summary Output Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --summary` to display a summary of the mirror operation, including the number of objects transferred and total size. This provides a quick overview of the synchronization. ```bash mc mirror --summary backup/ s3/archive ``` -------------------------------- ### Create Bucket using mc Source: https://github.com/minio/mc/blob/master/README.md Creates a new bucket on the specified alias. The command `mb` stands for 'make bucket'. ```bash mc mb play/mybucket ``` -------------------------------- ### mc admin config - Manage Server Configuration Source: https://context7.com/minio/mc/llms.txt Manage MinIO server configuration settings. ```APIDOC ## mc admin config - Manage Server Configuration ### Description Manage MinIO server configuration settings. ### Method `admin config` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **get**: Retrieves configuration settings. - **set**: Sets a configuration value. - **reset**: Resets a configuration section to default. - **export**: Exports the configuration. - **import**: Imports the configuration. - **history**: Views configuration history. - **restore**: Restores configuration from history. #### Query Parameters for `get` - **key** (string) - Optional - Specific configuration key to retrieve. #### Query Parameters for `set` - **key** (string) - The configuration key to set. - **value** (string) - The value to set for the key. ### Request Example ```bash # Get all config mc admin config get myminio # Get specific config key mc admin config get myminio region # Set config value mc admin config set myminio region name=us-west-1 # Reset config to default mc admin config reset myminio region # Export config mc admin config export myminio > config.txt # Import config mc admin config import myminio < config.txt # View config history mc admin config history myminio # Restore config from history mc admin config restore myminio ``` ``` -------------------------------- ### List All Users Source: https://context7.com/minio/mc/llms.txt Retrieve a list of all user accounts configured on the MinIO server using `mc admin user list`. This helps in auditing user access. ```bash mc admin user list myminio ``` -------------------------------- ### List All Policies Source: https://context7.com/minio/mc/llms.txt View a list of all IAM policies currently configured on the MinIO server using `mc admin policy list`. This provides an overview of access control settings. ```bash mc admin policy list myminio ``` -------------------------------- ### List Buckets and Objects Source: https://context7.com/minio/mc/llms.txt List buckets and objects with support for versioning, incomplete uploads, and time-based filtering. Provides recursive listing and summary information. ```bash mc ls s3 ``` ```bash mc ls --recursive s3/mybucket ``` ```bash mc ls s3/mybucket/photos/ ``` ```bash mc ls --incomplete s3/mybucket ``` ```bash mc ls --rewind 2020.01.01 s3/mybucket ``` ```bash mc ls --rewind 7d s3/mybucket ``` ```bash mc ls --versions s3/mybucket ``` ```bash mc ls --summarize s3/mybucket/ ``` ```bash mc ls --storage-class 'GLACIER' s3/mybucket ``` -------------------------------- ### Enable Bucket Versioning Source: https://context7.com/minio/mc/llms.txt Activate object versioning for a bucket using `mc version enable`. Once enabled, previous versions of objects are retained. ```bash mc version enable myminio/mybucket ``` -------------------------------- ### Copy Objects using mc Source: https://github.com/minio/mc/blob/master/README.md Copies a local file ('myobject.txt') to a bucket on the specified alias ('play/mybucket'). The output shows the progress and details of the copy operation. ```bash mc cp myobject.txt play/mybucket ``` -------------------------------- ### List Lifecycle Rules Source: https://context7.com/minio/mc/llms.txt View all configured lifecycle rules for a bucket using `mc ilm rule list`. This provides an overview of object lifecycle management policies. ```bash mc ilm rule list myminio/mybucket ``` -------------------------------- ### Active-Active Cross-Site Replication Source: https://context7.com/minio/mc/llms.txt Configure active-active replication between two sites using `mc mirror --active-active`. This ensures data is synchronized in both directions, providing high availability. ```bash # Site-A: mc mirror --active-active siteA siteB # Site-B: mc mirror --active-active siteB siteA ``` -------------------------------- ### Watch Bucket for All Events Source: https://context7.com/minio/mc/llms.txt Monitor a bucket for all real-time object events. ```bash mc watch myminio/mybucket ``` -------------------------------- ### List Event Notifications Source: https://context7.com/minio/mc/llms.txt List all configured event notifications for a specific bucket. ```bash mc event list myminio/mybucket ``` -------------------------------- ### Watch and Copy Matching Files Continuously Source: https://context7.com/minio/mc/llms.txt Use `mc find --watch --exec` to continuously monitor a bucket for new objects matching a pattern and execute a command (e.g., `mc cp`) on them. This is useful for real-time processing. ```bash mc find s3/bucket --name "*.jpg" --watch --exec "mc cp {} play/bucket" ``` -------------------------------- ### Create Policy from JSON File Source: https://context7.com/minio/mc/llms.txt Define a new IAM policy by providing a JSON configuration file to `mc admin policy create`. This allows for complex access control rules. ```bash mc admin policy create myminio mypolicy policy.json ``` -------------------------------- ### Find by Metadata (MinIO Server Only) Source: https://context7.com/minio/mc/llms.txt Use `mc find --metadata` to search for objects based on their metadata attributes. This feature is specific to MinIO servers. ```bash mc find s3/bucket --metadata "Content-Type=image/*" ``` -------------------------------- ### Shell Aliases for mc Source: https://github.com/minio/mc/blob/master/README.md Sets up common Unix command aliases to use `mc` commands instead. This allows you to use familiar commands like `ls`, `cp`, `cat`, and `mkdir` with MinIO storage. ```bash alias ls='mc ls' alias cp='mc cp' alias cat='mc cat' alias mkdir='mc mb' alias pipe='mc pipe' alias find='mc find' ``` -------------------------------- ### Find Objects by Size Range and Generate URLs Source: https://context7.com/minio/mc/llms.txt Use `mc find --larger`, `--smaller`, and `--print {url}` to find objects within a specific size range and generate their public URLs. This is useful for inventory and sharing. ```bash mc find s3 --larger 64MB --smaller 1GB --print {url} ``` -------------------------------- ### Enable User Account Source: https://context7.com/minio/mc/llms.txt Re-enable a previously disabled user account using `mc admin user enable`. This restores the user's access privileges. ```bash mc admin user enable myminio newuser ``` -------------------------------- ### Export Configuration Source: https://context7.com/minio/mc/llms.txt Export the current MinIO server configuration to a file using `mc admin config export`. This is useful for backup or sharing configurations. ```bash mc admin config export myminio > config.txt ``` -------------------------------- ### View Configuration History Source: https://context7.com/minio/mc/llms.txt Display the history of configuration changes made to the MinIO server using `mc admin config history`. Each change is associated with a unique history ID. ```bash mc admin config history myminio ``` -------------------------------- ### Pull and Run Stable Docker Image Source: https://github.com/minio/mc/blob/master/README.md Pulls the latest stable MinIO Client Docker image and runs a command against the MinIO play environment. ```bash docker pull minio/mc docker run minio/mc ls play ``` -------------------------------- ### Output Server Info in JSON Source: https://context7.com/minio/mc/llms.txt Obtain server information in JSON format by appending the `--json` flag to `mc admin info`. This is useful for programmatic parsing and integration. ```bash mc admin info play/ --json ``` -------------------------------- ### Export Lifecycle Configuration Source: https://context7.com/minio/mc/llms.txt Export the current lifecycle configuration of a bucket to a JSON file using `mc ilm rule export`. This is useful for backup and migration. ```bash mc ilm rule export myminio/mybucket > lifecycle.json ``` -------------------------------- ### Pull and Run Edge Docker Image Source: https://github.com/minio/mc/blob/master/README.md Pulls the latest edge version of the MinIO Client Docker image and runs a command against the MinIO play environment. ```bash docker pull minio/mc:edge docker run minio/mc:edge ls play ``` -------------------------------- ### Summarize Including All Versions Source: https://context7.com/minio/mc/llms.txt Use `mc du --versions` to include all object versions in the storage summary. This provides a complete view of data including historical versions. ```bash mc du --versions s3/jazz-songs/ ``` -------------------------------- ### Find by Tags (MinIO Server Only) Source: https://context7.com/minio/mc/llms.txt Use `mc find --tags` to search for objects based on their associated tags. This functionality is available on MinIO servers. ```bash mc find s3/bucket --tags "environment=production" ``` -------------------------------- ### Mirror with Prometheus Monitoring Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --monitoring-address` to enable Prometheus metrics collection during a mirror operation. This allows for monitoring the progress and performance of the synchronization. ```bash mc mirror --monitoring-address localhost:8081 backup/ s3/archive ``` -------------------------------- ### Watch Bucket with Prefix Filter Source: https://context7.com/minio/mc/llms.txt Monitor a bucket for events on objects matching a specific prefix. ```bash mc watch myminio/mybucket --prefix photos/ ``` -------------------------------- ### Summarize Data at Specific Date Source: https://context7.com/minio/mc/llms.txt Employ `mc du --rewind` to view the storage usage as it was at a particular point in time. This is helpful for historical analysis or auditing. ```bash mc du --rewind "2020.01.01" s3/jazz-songs/ ``` -------------------------------- ### List Active Shares Source: https://context7.com/minio/mc/llms.txt Use `mc share list` to display all currently active presigned URLs. This helps in managing temporary access links. ```bash mc share list ``` -------------------------------- ### Watch Specific Events Source: https://context7.com/minio/mc/llms.txt Monitor a bucket for specific types of events, such as 'put' or 'delete'. ```bash mc watch myminio/mybucket --events put,delete ``` -------------------------------- ### Reset Configuration to Default Source: https://context7.com/minio/mc/llms.txt Revert a specific configuration key back to its default value using `mc admin config reset`. This is helpful for troubleshooting or reverting unwanted changes. ```bash mc admin config reset myminio region ``` -------------------------------- ### Mirror with Exclusion Patterns Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --exclude` to mirror objects while excluding files that match specified patterns. This allows for selective synchronization. ```bash mc mirror --exclude ".*" --exclude "*.temp" s3/test ~/test ``` -------------------------------- ### mc version - Manage Bucket Versioning Source: https://context7.com/minio/mc/llms.txt Manage bucket versioning configuration. ```APIDOC ## mc version - Manage Bucket Versioning ### Description Manage bucket versioning configuration. ### Method `version` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **enable**: Enables versioning for a bucket. - **suspend**: Suspends versioning for a bucket. - **info**: Gets the versioning status of a bucket. ### Request Example ```bash # Enable versioning mc version enable myminio/mybucket # Suspend versioning mc version suspend myminio/mybucket # Get versioning status mc version info myminio/mybucket ``` ``` -------------------------------- ### Add Transition Rule to Different Storage Class Source: https://context7.com/minio/mc/llms.txt Define a lifecycle rule to transition objects to a different storage class (e.g., GLACIER) after a specified period using `mc ilm rule add --transition-days`. ```bash mc ilm rule add --transition-days 30 --storage-class GLACIER myminio/mybucket ``` -------------------------------- ### Continuous Watch Mode with Removal Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --remove --watch` for continuous synchronization of a source directory to a target, removing extraneous files on the target. The `--watch` flag enables real-time monitoring for changes. ```bash mc mirror --remove --watch /var/lib/backups play/backups ``` -------------------------------- ### Mirror Local Folder to S3 Source: https://context7.com/minio/mc/llms.txt Use `mc mirror` to synchronize a local folder to an S3 bucket. This is useful for backing up local data to cloud storage. ```bash mc mirror backup/ s3/archive ``` -------------------------------- ### Recursive Upload URL Source: https://context7.com/minio/mc/llms.txt Generate a presigned URL for recursively uploading a directory's contents using `mc share upload --recursive`. This is convenient for bulk uploads. ```bash mc share upload --recursive --expire=2h s3/backup/2007-Mar-2/backup/ ``` -------------------------------- ### mc ilm rule - Bucket Lifecycle Management Source: https://context7.com/minio/mc/llms.txt Configure object lifecycle rules for automatic transitions and expirations. ```APIDOC ## mc ilm rule - Bucket Lifecycle Management (ILM) ### Description Configure object lifecycle rules for automatic transitions and expirations. ### Method `ilm rule` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **add**: Adds a lifecycle rule. - **list**: Lists all lifecycle rules. - **remove**: Removes a lifecycle rule. - **export**: Exports the lifecycle configuration. - **import**: Imports the lifecycle configuration. #### Query Parameters for `add` - **--expire-days** (integer) - Optional - Number of days after which objects expire. - **--prefix** (string) - Optional - Filters rules by object prefix. - **--transition-days** (integer) - Optional - Number of days after which objects transition to another storage class. - **--storage-class** (string) - Optional - The target storage class for transition (e.g., "GLACIER"). #### Query Parameters for `remove` - **--id** (string) - Required - The ID of the rule to remove. ### Request Example ```bash # Add lifecycle rule to expire objects after 30 days mc ilm rule add --expire-days 30 myminio/mybucket # Add lifecycle rule with prefix filter mc ilm rule add --expire-days 90 --prefix "logs/" myminio/mybucket # Add transition rule to move to different storage class mc ilm rule add --transition-days 30 --storage-class GLACIER myminio/mybucket # List lifecycle rules mc ilm rule list myminio/mybucket # Remove lifecycle rule mc ilm rule remove --id "rule-id" myminio/mybucket # Export lifecycle configuration mc ilm rule export myminio/mybucket > lifecycle.json # Import lifecycle configuration mc ilm rule import myminio/mybucket < lifecycle.json ``` ``` -------------------------------- ### Restore Configuration from History Source: https://context7.com/minio/mc/llms.txt Revert the MinIO server configuration to a previous state by using `mc admin config restore` with a specific history ID. This is a powerful tool for recovering from configuration errors. ```bash mc admin config restore myminio ``` -------------------------------- ### Mirror Bucket from MinIO to S3 Source: https://context7.com/minio/mc/llms.txt Use `mc mirror` to synchronize objects from a MinIO bucket to an S3 bucket. This command supports various options for filtering and control. ```bash mc mirror play/photos/2014 s3/backup-photos ``` -------------------------------- ### mc du - Summarize Disk Usage Source: https://context7.com/minio/mc/llms.txt Commands to summarize disk usage with options for depth, specific dates, versions, and recursion. ```APIDOC ## mc du - Summarize Disk Usage ### Description Commands to summarize disk usage with options for depth, specific dates, versions, and recursion. ### Method `du` ### Endpoint `/minio/mc` ### Parameters #### Query Parameters - **--depth** (integer) - Optional - Limits the summarization depth. - **--rewind** (string) - Optional - Summarizes usage at a specific date (e.g., "YYYY.MM.DD"). - **--versions** (boolean) - Optional - Includes all versions in the summarization. - **--recursive** (boolean) - Optional - Performs a recursive summarization. ### Request Example ```bash # Summarize with depth limit mc du --depth=2 s3/jazz-songs/louis/ # Summarize at specific date mc du --rewind "2020.01.01" s3/jazz-songs/ # Summarize including all versions mc du --versions s3/jazz-songs/ # Recursive summarization mc du --recursive s3/jazz-songs/ ``` ``` -------------------------------- ### Add Lifecycle Rule with Prefix Filter Source: https://context7.com/minio/mc/llms.txt Create a lifecycle rule that applies only to objects matching a specific prefix, in addition to expiration settings, using `mc ilm rule add --prefix`. ```bash mc ilm rule add --expire-days 90 --prefix "logs/" myminio/mybucket ``` -------------------------------- ### Display Specific Object Version Source: https://context7.com/minio/mc/llms.txt Use `mc cat --vid` to display a specific version of an object. This allows access to historical data without affecting the current version. ```bash mc cat --vid "3ddac055-89a7-40fa-8cd3-530a5581b6b8" play/my-bucket/my-object ``` -------------------------------- ### Generate Upload URL Source: https://context7.com/minio/mc/llms.txt The `mc share upload` command generates a presigned URL for uploading objects. This is useful for granting temporary upload access without credentials. ```bash mc share upload s3/backup/2006-Mar-1/backup.tar.gz ``` -------------------------------- ### Summarize Disk Usage of Bucket Source: https://context7.com/minio/mc/llms.txt Use `mc du` to recursively summarize the disk usage of a bucket or prefix. This command provides insights into storage consumption. ```bash mc du s3/jazz-songs ``` -------------------------------- ### Watch Bucket Recursively Source: https://context7.com/minio/mc/llms.txt Monitor a bucket and all its subdirectories for real-time object events. ```bash mc watch --recursive myminio/mybucket ``` -------------------------------- ### Mirror with Overwrite Enabled Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --overwrite` to mirror objects and overwrite existing files on the target if they have the same name. This ensures the target reflects the source. ```bash mc mirror --overwrite s3/miniocloud miniocloud-backup ``` -------------------------------- ### Set Cloud Storage Alias Source: https://github.com/minio/mc/blob/master/README.md Use this command to add a new alias for a cloud storage service. Replace placeholders with your specific details. The `--api` and `--path` flags are optional for specifying API signature and bucket lookup type. ```bash mc alias set --api --path ``` -------------------------------- ### mc admin policy - Manage IAM Policies Source: https://context7.com/minio/mc/llms.txt Manage IAM policies for MinIO server access control. ```APIDOC ## mc admin policy - Manage IAM Policies ### Description Manage IAM policies for MinIO server access control. ### Method `admin policy` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **create**: Creates a policy from a JSON file. - **list**: Lists all policies. - **info**: Gets policy information. - **attach**: Attaches a policy to a user or group. - **detach**: Detaches a policy from a user or group. - **remove**: Removes a policy. #### Query Parameters for `attach` and `detach` - **--user** (string) - The username to attach/detach the policy from. - **--group** (string) - The group name to attach/detach the policy from. ### Request Example ```bash # Create policy from JSON file mc admin policy create myminio mypolicy policy.json # List all policies mc admin policy list myminio # Get policy info mc admin policy info myminio mypolicy # Attach policy to user mc admin policy attach myminio mypolicy --user newuser # Attach policy to group mc admin policy attach myminio mypolicy --group mygroup # Detach policy from user mc admin policy detach myminio mypolicy --user newuser # Remove policy mc admin policy remove myminio mypolicy ``` ``` -------------------------------- ### mc share - Generate Shareable URLs Source: https://context7.com/minio/mc/llms.txt Generate presigned URLs for temporary object access without requiring credentials. ```APIDOC ## mc share - Generate Shareable URLs ### Description Generate presigned URLs for temporary object access without requiring credentials. ### Method `share` ### Endpoint `/minio/mc` ### Parameters #### Query Parameters - **--expire** (string) - Optional - Custom expiry duration (e.g., "4h", "120h"). Defaults to 7 days for download. - **--content-type** (string) - Optional - Restricts the content type for upload URLs. - **--recursive** (boolean) - Optional - Generates URLs for recursive operations. ### Request Example ```bash # Generate download URL (default 7 days expiry) mc share download s3/backup/2006-Mar-1/backup.tar.gz # Generate download URL with custom expiry mc share download --expire=4h s3/backup/important.zip # Generate curl command for upload mc share upload s3/backup/2006-Mar-1/backup.tar.gz # Generate upload URL with expiry mc share upload --expire=120h s3/backup/2007-Mar-2/ # Upload with content-type restriction mc share upload --expire=2h --content-type=image/png s3/backup/2007-Mar-2/ # Recursive upload URL mc share upload --recursive --expire=2h s3/backup/2007-Mar-2/backup/ # List active shares mc share list ``` ``` -------------------------------- ### mc admin service - Manage Server Services Source: https://context7.com/minio/mc/llms.txt Control MinIO server services including restart, stop, and freeze operations. ```APIDOC ## mc admin service - Manage Server Services ### Description Control MinIO server services including restart, stop, and freeze operations. ### Method `admin service` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **restart**: Restarts the MinIO server. - **stop**: Stops the MinIO server. - **freeze**: Freezes the server, rejecting new requests. - **unfreeze**: Unfreezes the server, allowing new requests. ### Request Example ```bash # Restart MinIO server mc admin service restart myminio/ # Stop MinIO server mc admin service stop myminio/ # Freeze server (reject new requests) mc admin service freeze myminio/ # Unfreeze server mc admin service unfreeze myminio/ ``` ``` -------------------------------- ### Watch Bucket with Suffix Filter Source: https://context7.com/minio/mc/llms.txt Monitor a bucket for events on objects matching a specific suffix. ```bash mc watch myminio/mybucket --suffix .png ``` -------------------------------- ### Mirror with Retry on Errors Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --retry` to automatically retry failed operations during a mirror. This increases the reliability of the synchronization process, especially over unstable networks. ```bash mc mirror --retry backup/ s3/archive ``` -------------------------------- ### Generate Download URL with Custom Expiry Source: https://context7.com/minio/mc/llms.txt Specify a custom expiration time for download URLs using the `--expire` flag. This allows for fine-grained control over temporary access duration. ```bash mc share download --expire=4h s3/backup/important.zip ``` -------------------------------- ### mc admin user - Manage Users Source: https://context7.com/minio/mc/llms.txt Manage MinIO users and access keys for IAM operations. ```APIDOC ## mc admin user - Manage Users ### Description Manage MinIO users and access keys for IAM operations. ### Method `admin user` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **add**: Adds a new user. - **list**: Lists all users. - **info**: Gets user information. - **disable**: Disables a user. - **enable**: Enables a user. - **remove**: Removes a user. ### Request Example ```bash # Add new user mc admin user add myminio newuser newuser123 # List all users mc admin user list myminio # Get user info mc admin user info myminio newuser # Disable user mc admin user disable myminio newuser # Enable user mc admin user enable myminio newuser # Remove user mc admin user remove myminio newuser ``` ``` -------------------------------- ### Unfreeze MinIO Server Source: https://context7.com/minio/mc/llms.txt Resume normal operations and allow new requests on a MinIO server that was previously frozen using `mc admin service unfreeze`. ```bash mc admin service unfreeze myminio/ ``` -------------------------------- ### Recursive Directory Summarization Source: https://context7.com/minio/mc/llms.txt The `mc du --recursive` command calculates storage usage for all objects within a bucket and its subdirectories. This is the default behavior if no depth is specified. ```bash mc du --recursive s3/jazz-songs/ ``` -------------------------------- ### Display Content from 10 Days Ago Source: https://context7.com/minio/mc/llms.txt Use `mc cat --rewind` to display the content of an object as it was at a specific time in the past. This is useful for historical data retrieval. ```bash mc cat --rewind 10d play/my-bucket/my-object ``` -------------------------------- ### Stream Object to mplayer Source: https://context7.com/minio/mc/llms.txt Use `mc cat` to stream object contents to standard output, which can then be piped to other commands like `mplayer` for playback. Supports versioning and encryption. ```bash mc cat s3/mysql-backups/kubecon-mysql-operator.mpv | mplayer - ``` -------------------------------- ### Stop MinIO Server Source: https://context7.com/minio/mc/llms.txt Gracefully stop the MinIO server service using `mc admin service stop`. Ensure all operations are completed before stopping. ```bash mc admin service stop myminio/ ``` -------------------------------- ### Find Objects with Specific Extension Source: https://context7.com/minio/mc/llms.txt Use `mc find --name` with a wildcard pattern to find objects with a specific file extension within a bucket. ```bash mc find s3/mybucket --name "*.txt" ``` -------------------------------- ### Mirror and Remove Extraneous Files on Target Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --remove` to synchronize objects and remove any files on the target that do not exist in the source. This keeps the target a true replica of the source. ```bash mc mirror --remove play/photos/2014 s3/backup-photos/2014 ``` -------------------------------- ### Copy Objects Between Storage Endpoints Source: https://context7.com/minio/mc/llms.txt Copy objects with support for encryption, metadata, retention policies, and parallel transfers. Use flags like `--recursive`, `--older-than`, `--newer-than`, `--attr`, `--storage-class`, `-a`, `--retention-mode`, `--legal-hold`, `--rewind`, `--tags`, and `--enc-s3` for advanced options. ```bash mc cp Music/*.ogg s3/jukebox/ ``` ```bash mc cp --recursive play/mybucket/myfolder/ s3/mybucket/ ``` ```bash mc cp --recursive backup/2014/ backup/2015/ play/archive/ ``` ```bash mc cp --older-than 7d10h play/mybucket/myfolder/ s3/mybucket/ ``` ```bash mc cp --newer-than 7d play/mybucket/myfolder/ ~/latest/ ``` ```bash mc cp --attr "key1=value1;key2=value2" Music/*.mp4 play/mybucket/ ``` ```bash mc cp --attr "Cache-Control=max-age=90000,min-fresh=9000" --recursive play/mybucket/myfolder/ s3/mybucket/ ``` ```bash mc cp --storage-class REDUCED_REDUNDANCY myobject.txt play/mybucket ``` ```bash mc cp -a myobject.txt play/mybucket ``` ```bash mc cp --retention-mode governance --retention-duration 1d locked.txt play/locked-bucket/ ``` ```bash mc cp --legal-hold on locked.txt play/locked-bucket/ ``` ```bash mc cp --rewind 10d -r play/mybucket/ /tmp/dest/ ``` ```bash mc cp -r --tags "category=prod&type=backup" ./data/ play/another-bucket/ ``` ```bash mc cp --recursive --enc-s3 "s3/documents" --enc-s3 "myminio/documents" s3/documents/ myminio/documents/ ``` -------------------------------- ### Find All Objects by Name Source: https://context7.com/minio/mc/llms.txt Use `mc find` to search for objects across all buckets based on their names. The `--name` flag accepts wildcards. ```bash mc find s3 --name "foo.jpg" ``` -------------------------------- ### Show Offline Nodes/Drives Source: https://context7.com/minio/mc/llms.txt Filter server information to display only offline nodes or drives by using the `--offline` flag with `mc admin info`. This helps in quickly identifying potential issues. ```bash mc admin info --offline play/ ``` -------------------------------- ### Find and Print Only Base Names Source: https://context7.com/minio/mc/llms.txt Use `mc find --print {base}` to find objects and print only their base names (without the path or extension). ```bash mc find s3/mybucket --name "*" --print {base} ``` -------------------------------- ### Mirror Encrypted Objects Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --enc-c` to mirror encrypted objects. Encryption keys must be provided for both source and target if they differ. This ensures data is encrypted in transit and at rest. ```bash mc mirror --enc-c "minio/archive=MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDA" --enc-c "s3/archive=MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5BBB" s3/archive/ minio/archive/ ``` -------------------------------- ### Find Using Regex Source: https://context7.com/minio/mc/llms.txt Use `mc find --regex` to find objects whose names match a given regular expression. This provides powerful pattern matching capabilities. ```bash mc find s3/photos --regex "(?i)\.(jpg|png|gif)$" ``` -------------------------------- ### Restart MinIO Server Source: https://context7.com/minio/mc/llms.txt Restart the MinIO server service for a specified alias using `mc admin service restart`. This is typically done after configuration changes or for maintenance. ```bash mc admin service restart myminio/ ``` -------------------------------- ### Read Encrypted Object Source: https://context7.com/minio/mc/llms.txt Use `mc cat --enc-c` to read an encrypted object. The encryption key must be provided. The content is then redirected to a local file. ```bash mc cat --enc-c "play/my-bucket/=MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDA" s3/mysql-backups/backups-201810.gz > /mnt/data/recent.gz ``` -------------------------------- ### Find with Path Prefix Pattern Source: https://context7.com/minio/mc/llms.txt Use `mc find --path` to search for objects that match a name pattern within a specific path prefix. This allows for more targeted searches within nested directories. ```bash mc find s3/photos --name "*.jpg" --path "*/album*/*" ``` -------------------------------- ### mc event - Event Notifications Source: https://context7.com/minio/mc/llms.txt Configure and monitor bucket event notifications. ```APIDOC ## mc event - Event Notifications ### Description Configure and monitor bucket event notifications. ### Method `event` ### Endpoint `/minio/mc` ### Parameters #### Subcommands - **add**: Adds a notification configuration. #### Query Parameters for `add` - **arn** (string) - Required - The ARN of the target (e.g., SQS queue). - **event** (string) - Required - Comma-separated list of events (e.g., "put,delete"). ### Request Example ```bash # Add notification to SQS queue mc event add myminio/mybucket arn:aws:sqs:us-east-1:account-id:queue --event put,delete ``` ``` -------------------------------- ### Remove User Account Source: https://context7.com/minio/mc/llms.txt Permanently delete a user account and all associated access keys from the MinIO server using `mc admin user remove`. This action is irreversible. ```bash mc admin user remove myminio newuser ``` -------------------------------- ### Concatenate Multiple Files Source: https://context7.com/minio/mc/llms.txt Use `mc cat` with a wildcard pattern to concatenate multiple files. This is useful for assembling parts of a larger file. ```bash mc cat part.* > complete.img ``` -------------------------------- ### Generate Upload URL with Expiry Source: https://context7.com/minio/mc/llms.txt Set a custom expiration time for upload URLs using the `--expire` flag. This ensures that upload links are only valid for a specified period. ```bash mc share upload --expire=120h s3/backup/2007-Mar-2/ ``` -------------------------------- ### Remove Non-Current Versions Older Than 10 Days (Dry Run) Source: https://context7.com/minio/mc/llms.txt Use `mc rm --recursive --force --versions --non-current --older-than --dry-run` to simulate the removal of non-current object versions older than a specified duration without actually deleting them. This is useful for testing. ```bash mc rm s3/docs/ --recursive --force --versions --non-current --older-than 10d --dry-run ``` -------------------------------- ### Dry-Run Healing Source: https://context7.com/minio/mc/llms.txt Simulate data healing operations without making any actual changes using `mc admin heal --dry-run`. This allows you to preview potential healing actions. ```bash mc admin heal --dry-run myminio/mybucket ``` -------------------------------- ### Squash Commits with git rebase Source: https://github.com/minio/mc/blob/master/CONTRIBUTING.md Consolidate your changes into a single commit for a cleaner pull request history using interactive rebase. ```bash git rebase -i ``` -------------------------------- ### Freeze MinIO Server Source: https://context7.com/minio/mc/llms.txt Prevent the MinIO server from accepting new requests by using `mc admin service freeze`. This is useful during maintenance windows to ensure data consistency. ```bash mc admin service freeze myminio/ ``` -------------------------------- ### Drop Incomplete Uploads Source: https://context7.com/minio/mc/llms.txt Use `mc rm --incomplete --recursive --force` to remove incomplete multipart uploads. This helps in cleaning up storage space occupied by unfinished uploads. ```bash mc rm --incomplete --recursive --force s3/jazz-songs/ ``` -------------------------------- ### Heal with Specific Prefix Source: https://context7.com/minio/mc/llms.txt Run data healing operations on objects within a specific prefix of a bucket using `mc admin heal myminio/mybucket/prefix/`. This narrows the scope of the healing process. ```bash mc admin heal myminio/mybucket/prefix/ ``` -------------------------------- ### Mirror Objects Older Than 30 Days Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --older-than` to mirror only objects that are older than a specified duration. This can be used for archiving or moving older data. ```bash mc mirror --older-than 30d s3/test ~/test ``` -------------------------------- ### Update Metadata on Existing Objects Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --attr` to update metadata attributes on existing objects during a mirror operation. This is useful for setting cache control or other headers. ```bash mc mirror --attr "Cache-Control=max-age=90000,min-fresh=9000" myminio/video-files myminio/video-files ``` -------------------------------- ### Rename mc to mcli Source: https://github.com/minio/mc/blob/master/CONFLICT.md This command renames the MinIO Client binary from 'mc' to 'mcli'. Use this if package managers require a different name to avoid conflicts with Midnight Commander. ```bash mv ./mc ./mcli ``` -------------------------------- ### Summarize Directory Depth Source: https://context7.com/minio/mc/llms.txt Use `mc du --depth` to summarize the size of objects within a specified directory depth. This is useful for understanding storage distribution at different levels. ```bash mc du --depth=2 s3/jazz-songs/louis/ ``` -------------------------------- ### Find Older Objects Excluding Pattern Source: https://context7.com/minio/mc/llms.txt Use `mc find --older-than` and `--ignore` to find objects older than a specified duration while excluding those matching a certain pattern. This helps in targeted cleanup or analysis. ```bash mc find s3 --older-than 2d5h10m --ignore "*.jpg" ``` -------------------------------- ### Mirror Files Newer Than Specified Duration Source: https://context7.com/minio/mc/llms.txt Use `mc mirror --newer-than` to mirror files that have been modified within a specified time frame. This ensures only recent changes are synchronized. ```bash mc mirror --newer-than "7d10h30m" backup/ s3/archive ``` -------------------------------- ### Add Lifecycle Rule to Expire Objects Source: https://context7.com/minio/mc/llms.txt Configure a lifecycle rule to automatically expire objects after a specified number of days using `mc ilm rule add --expire-days`. This helps manage storage costs. ```bash mc ilm rule add --expire-days 30 myminio/mybucket ``` -------------------------------- ### Attach Policy to Group Source: https://context7.com/minio/mc/llms.txt Assign an IAM policy to a user group using `mc admin policy attach --group`. This allows for managing permissions for multiple users simultaneously. ```bash mc admin policy attach myminio mypolicy --group mygroup ``` -------------------------------- ### Suspend Bucket Versioning Source: https://context7.com/minio/mc/llms.txt Temporarily halt object versioning for a bucket using `mc version suspend`. New objects will overwrite existing ones without creating new versions. ```bash mc version suspend myminio/mybucket ``` -------------------------------- ### Add Notification with Prefix Filter Source: https://context7.com/minio/mc/llms.txt Add an event notification to a bucket with a prefix filter. This ensures notifications are only triggered for objects matching the specified prefix. ```bash mc event add myminio/mybucket arn:aws:sqs:us-east-1:account-id:queue --prefix images/ ``` -------------------------------- ### Add Notification to SQS Queue Source: https://context7.com/minio/mc/llms.txt Configure event notifications for a bucket to be sent to an SQS queue using `mc event add`. Specify the ARN of the SQS queue and the events to notify on (e.g., 'put', 'delete'). ```bash mc event add myminio/mybucket arn:aws:sqs:us-east-1:account-id:queue --event put,delete ``` -------------------------------- ### Concatenate File and STDIN Source: https://context7.com/minio/mc/llms.txt Use `mc cat` with '-' to concatenate a file with standard input. The output is redirected to another file. ```bash mc cat file1.txt - > file.txt ```