Download MinIO

# Download Url
# https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-single-drive.html
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20230112020616.0.0_amd64.deb -O minio.deb
dpkg -i minio.deb

Create MinIO config file

$ cat /etc/default/minio
MINIO_VOLUMES="/data/MinIO"
MINIO_OPTS="--console-address :9001"
MINIO_ROOT_USER=<minio-root-username>
MINIO_ROOT_PASSWORD=<minio-root-password>
MINIO_BROWSER_REDIRECT_URL="https://<minio-dashboard-domain>"
MINIO_SERVER_URL="https://<minio-storage-service-domain>"

Change systemd unit file username & group to root

$ cat /etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
 
[Service]
WorkingDirectory=/usr/local
 
User=root
Group=root
ProtectProc=invisible
 
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/shell -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
 
# Let systemd restart this service always
Restart=always
 
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=1048576
 
# Specifies the maximum number of threads this process can create
TasksMax=infinity
 
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
 
[Install]
WantedBy=multi-user.target
 
# Built for ${project.name}-${project.version} (${project.name})

Set storage domain IP to Localhost

vim /etc/hosts
-----
127.0.0.1 <minio-dashboard-domain>
127.0.0.1 <minio-storage-service-domain>
-----

Set readonly policy to buckets

{
    "Statement": [
        {
            "Action": [
                "s3:GetBucketLocation"
            ],
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Resource": [
                "arn:aws:s3:::<your-bucket-name>"
            ]
        },
        {
            "Action": [
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Resource": [
                "arn:aws:s3:::<your-bucket-name>/*"
            ]
        }
    ],
    "Version": "2012-10-17"
}

Download mc binary

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

Add alias to mc

mc alias set local http://127.0.0.1:9000 <minio-root-username> <minio-root-password>

Delete files

mc rm -r --force --dangerous --versions local/<your-bucket-name>/<need-to-delete-files>

Delete Buckets

mc rb local/<your-bucket-name> --force

Use mirror to sync files

mc mirror --overwrite --remove /path/to/source/directory/ local/<your-bucket-name>/directory/