S3Safe is simple a lightweight CLI tool for backing up and restoring data from Amazon S3 and S3-compatible storage.
# Using Go
go install github.com/jkaninda/s3safe@latest
# Using Docker
docker pull jkaninda/s3safe:latestCopy .env.example to .env and configure your S3 credentials:
AWS_REGION=us-east-1
AWS_ENDPOINT=https://s3.wasabisys.com
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_KEY=your_secret_key
AWS_BUCKET=your_bucket_name
AWS_FORCE_PATH="true" # For path-style URLs
AWS_DISABLE_SSL="false" # Set "true" for non-HTTPS endpoints| Option | Short | Description |
|---|---|---|
--exclude |
-e |
Exclude files/directories (comma-separated patterns) |
--recursive |
-r |
Process directories recursively |
--path |
-p |
Source directory path |
--dest |
-d |
Destination path (in S3 or local filesystem) |
--file |
-f |
Process single file instead of directory |
--ignore-errors |
-i |
Continue on errors during restore |
--env-file |
Custom environment file (default: .env) | |
--help |
-h |
Show help message |
--version |
-v |
Show version information |
| Option | Short | Description |
|---|---|---|
--compress |
-c |
Compress before upload (creates .tar.gz) |
--timestamp |
-t |
Add timestamp to compressed filename |
| Option | Short | Description |
|---|---|---|
--decompress |
-D |
Decompress after download |
--force |
Force restore to destination path, overwrite existing files |
Backup directory (compressed):
s3safe backup -p ./backups -d /s3path --compress --timestampBackup single file:
s3safe backup --file data.db --dest /s3path/db-backups --compressNon-compressed directory backup:
s3safe backup -p ./backups -d /s3path/backups -rRestore compressed backup:
s3safe restore -p /s3path/backup.tar.gz -d ./backups --decompressRestore directory (recursive):
s3safe restore --path /s3path --dest ./backups --recursiveBackup with Docker:
docker run --rm --env-file .env \
-v "./backups:/backups" \
jkaninda/s3safe:latest \
backup --path /backups -d s3path --compressRestore with Docker:
docker run --rm --env-file .env \
-v "./restored:/restored" \
jkaninda/s3safe:latest \
restore --path s3path/backup.tar.gz -d /restored --decompressMIT License - See LICENSE for details.