Helper scripts for setup and administration.
Python dependencies only - no external tools required:
pip install -r tools/requirements.txtThis installs:
minio- MinIO Python SDK (S3 + Admin API)rich- Beautiful console outputurllib3- HTTP clientpython-dotenv- Load .env file
Creates and configures a MinIO bucket with proper IAM setup for the backup application.
| Resource | Default Name | Purpose |
|---|---|---|
| Bucket | github-backups |
Storage for backup files |
| Policy | pGitHubBackups |
Permissions for bucket access |
| User | github-backups |
IAM user with policy attached |
The user is created with a 64-character password to prevent MinIO Console login. In MinIO, user credentials ARE S3 credentials (user_name = access_key, password = secret_key).
# Show help and available actions
python tools/setup-bucket.py
# Check current status of bucket and IAM resources
python tools/setup-bucket.py --status
# Update policy if permissions don't match
python tools/setup-bucket.py --update
# Full setup - create bucket, policy, user
python tools/setup-bucket.py --create
# Setup with custom endpoint
python tools/setup-bucket.py --create \
--endpoint https://minio.example.com \
--admin-key admin \
--admin-secret supersecret
# Setup with custom names
python tools/setup-bucket.py --create \
--bucket my-backups \
--policy pMyBackups \
--user my-backup-user
# Don't update .env file after setup
python tools/setup-bucket.py --create --no-update-env| Action | Command | Description |
|---|---|---|
| Help | python tools/setup-bucket.py |
Shows help and available actions |
| Status | python tools/setup-bucket.py --status |
Shows what exists and if permissions match |
| Update | python tools/setup-bucket.py --update |
Updates policy if permissions differ |
| Setup | python tools/setup-bucket.py --create |
Creates bucket, policy, user with service account |
The script reads these environment variables as defaults:
| Variable | Description |
|---|---|
S3_ENDPOINT_URL |
MinIO endpoint URL |
S3_BUCKET |
Bucket name |
S3_REGION |
S3 region |
MINIO_ROOT_USER |
Admin access key (temporary) |
MINIO_ROOT_PASSWORD |
Admin secret key (temporary) |
Security Notice:
MINIO_ROOT_USERandMINIO_ROOT_PASSWORDare only needed to run this setup script. Remove them from your.envfile after setup! The script creates a dedicated service user with minimal permissions - you don't need admin credentials for normal operation.
On success, the script:
- Creates bucket and IAM policy
- Creates user with 64-character password (no console login)
- Attaches policy directly to user
- Prints S3 credentials to console
- Updates the
.envfile with:S3_ACCESS_KEYS3_SECRET_KEYS3_BUCKETS3_ENDPOINT_URLS3_REGION
The script is idempotent - you can run it multiple times:
- Existing bucket is kept (not recreated)
- Policy is updated with current permissions
- Existing user is preserved (credentials not changed)
Note: If user already exists, you won't get new credentials. Delete the user in MinIO Console first if you need to regenerate.
The generated policy includes all permissions needed for backup operations:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListMultipartUploadParts",
"s3:AbortMultipartUpload"
],
"Resource": [
"arn:aws:s3:::github-backups",
"arn:aws:s3:::github-backups/*"
]
}]
}