1. configure Minio
1.1. Connect to Server
create policy
mc config host add --insecure [SESSION] https://ip:9443 key secret --api s3v4
e.g.
mc config host add --insecure mysession https://83.212.119.119:9443 mykey mysecret --api s3v4
1.2. Create policy
create Default policy file: test.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
""
]
},
"Action": [
"s3:GetBucketLocation", (1)
"s3:HeadBucket", (1)
"s3:ListBucket", (1)
"s3:ListBucketMultipartUploads" (1)
],
"Resource": [
"arn:aws:s3:::test" (2)
]
},
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:DeleteObject", (3)
"s3:GetObject", (3)
"s3:ListMultipartUploadParts", (3)
"s3:PutObject" (3)
],
"Resource": [
"arn:aws:s3:::test/*" (4)
]
}
]
}
1.3. Apply policy
create policy
#!/bin/bash
mc mb --insecure mymsession/test (1)
mc admin policy add --insecure mymisession test ./test.json (2)
mc admin user add --insecure mymsession usertest bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd (3)
mc admin policy set --insecure mymsession test user=usertest (4)
1 | create bucket |
2 | Apply policy |
3 | create user |
4 | Apply policy User2bucket |
1.4. Sync local2Server
sync local2server
export MINIO_MIRROR_PARAMETERS="--delete"
export MINIO_SERVER_URL="ip:9443" (1)
export MINIO_PROT=https
export MINIO_SERVER_DOCUMENTROOT="/home/user/syncdir" (2)
export MINIO_WEB_BUCKET=test1
export MINIO_WEB_PASS="bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd"
export AWS_CONFIG_FILE="$HOME/.aws/config"
export AWS_ACCESS_KEY_ID=$MINIO_WEB_BUCKET
export AWS_SECRET_ACCESS_KEY=$MINIO_WEB_PASS
aws --endpoint-url $MINIO_PROT://$MINIO_SERVER_URL s3 sync MINIO_SERVER_DOCUMENTROOT s3://$MINIO_WEB_BUCKET $MINIO_MIRROR_PARAMETERS
1 | Minio Server ip |
2 | Directory sync |
1.5. Sync Server2Local
sync server2local
export MINIO_MIRROR_PARAMETERS="--delete"
export MINIO_SERVER_URL="ip:9443" (1)
export MINIO_PROT=https
export MINIO_SERVER_DOCUMENTROOT="/var/www/html" (2)
export MINIO_WEB_BUCKET=test
export MINIO_WEB_PASS="bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd"
export AWS_CONFIG_FILE="$HOME/.aws/config"
export AWS_ACCESS_KEY_ID=$MINIO_WEB_BUCKET
export AWS_SECRET_ACCESS_KEY=$MINIO_WEB_PASS
aws --endpoint-url $MINIO_PROT://$MINIO_SERVER_URL s3 sync s3://$MINIO_WEB_BUCKET $MINIO_SERVER_DOCUMENTROOT $MINIO_MIRROR_PARAMETERS
1 | Minio Server ip |
2 | Directory sync |
1.6. Docker-compose env
sync docker-compose env
environment: (1)
- MINIO_MIRROR_PARAMETERS= --delete
- MINIO_SERVER_URL=ip:9443
- MINIO_PROT=https
- MINIO_SERVER_DOCUMENTROOT=/var/www/html
- MINIO_WEB_BUCKET=test
- MINIO_WEB_PASS=bfksdkdjhdbhfbsdhbhf79fcbc7idjfdsjfsdbhfbhdbfhsd
- AWS_CONFIG_FILE=/home/user/.aws/config
1 | add env to docker-comose |
1.7. Automating sync with cron
crond file
*/15 * * * * root /PATH/local2server >> /var/log/usercron.log 2>&1 / (1)
1 | Every 15 minutes |