DEV Community

Peon Sh
Peon Sh

Posted on Originally published at peon.sh

Self-Host MinIO: S3-Compatible Object Storage on Your Own Server

Use S3-compliant object storage with MinIO for file upload, data backup and media storage. Setup, policies for buckets and when to use managed R2/B2 services.

Why the S3 API is the point
All frameworks, backup systems and SDKs communicate via S3 API, and this is how object storage communication works nowadays. It's implemented in your filesystem with MinIO, meaning Django-storages, Laravel flysystem, rclone, scripts for pg_dump backups and any other tool will continue working without changes, pointing only to the endpoint hosted on your server. Applications designed for MinIO can later be changed to AWS S3, Cloudflare R2 or Backblaze B2 using four env variables.

Deployment
Start the MinIO container using a volume from your biggest hard drive with two routed domains: one domain for the S3 API ( s3.example.com on port 9000) and another domain for the MinIO web console ( minio.example.com on port 9001). Provide your credentials via environment variables and use them once to set your per-application credentials for each bucket.

MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=

per-app keys via console or:

mc admin user add local app-uploads
mc admin policy attach local readwrite-uploads --user app-uploads
What is great about it for a VPS
App user uploads on a single server: network traffic to/from the private network, zero costs for egress, microsecond latency

Backup target for databases/volumes from your other services

Media origin behind a CDN: use Cloudflare on top of a publicly readable bucket and keep MinIO inexpensive

Development/test S3 with production semantics without credentials

The honest durability caveat
One disk on one VPS hosting MinIO is not durable enough to keep anything valuable without a backup. There are two ways to deal with this problem: either use it as working storage with another copy of your data elsewhere, or replicate it somewhere else: mc mirror --watch to Backblaze B2 or R2 will provide an offsite backup for around half a cent per GB-month. Most importantly, do not rely on MinIO on your server as your server’s sole backup destination.

MinIO vs just using R2/B2 directly
In case your sole requirement is an archival place for data, avoid the hassle of setting up the server yourself and simply go with either R2 or B2; it is very affordable, and someone else will take care of the disks for you. In case when data locality is required, in case your data has to be kept on your premises due to regulations, or when egress free development storage can save you money, go with MinIO.

Top comments (0)