Amazon S3 Storage
1. Tạo S3 bucket
- Đăng nhập AWS Console → S3
- Click Create bucket
- Bucket name: tên unique global (vd
sl-migrations-backup-yourname) - Region: chọn region gần server WordPress nhất
- Block all public access: GIỮ NGUYÊN (không disable)
- Versioning: Disabled (tiết kiệm dung lượng)
- Create
2. Tạo IAM user
- AWS Console → IAM → Users → Add users
- Name:
sl-migrations-backup - Access type: Programmatic access
- Permissions → Attach policies directly → Create policy (xem IAM Policy Setup)
- Lưu Access Key ID và Secret Access Key
3. Thêm storage trong plugin
SL Migrations → Storage → Add New → Amazon S3:
| Field | Value |
|---|---|
| Storage Name | Tên hiển thị, vd "S3 Backup" |
| Access Key | Lấy từ IAM bước 2 |
| Secret Key | Lấy từ IAM bước 2 |
| Bucket | Tên bucket |
| Region | Region của bucket |
| Storage Folder | backups/ (tùy chọn) |
Click Test Connection → phải thấy success.
Save.
4. Cấu hình storage cho package
Packages → Create New → Storage → tick "S3 Backup".
Plugin sẽ:
- Build archive local
- Upload lên S3 sau khi build xong
- (Tùy chọn) Xóa bản local sau khi upload thành công
5. Restore từ S3
Packages → Import → From Storage → chọn S3 → list archive → chọn archive → Import.
Hoặc tải về local trước qua AWS Console hoặc AWS CLI:
aws s3 cp s3://your-bucket/backups/archive.daf .
Retention policy
Plugin hỗ trợ tự động xóa backup cũ:
Storage → Edit S3 → Max Packages: số lượng backup giữ trong S3. Khi vượt giới hạn, plugin xóa backup cũ nhất.
Lifecycle rule trên S3 (khuyến nghị)
Cấu hình lifecycle rule trên bucket để tự move backup cũ sang Glacier (rẻ hơn):
{
"Rules": [{
"Id": "Move to Glacier after 30 days",
"Status": "Enabled",
"Filter": { "Prefix": "backups/" },
"Transitions": [{
"Days": 30,
"StorageClass": "GLACIER"
}]
}]
}