S3 - KeynesYouDigIt/Knowledge GitHub Wiki
Buckets
Cheap file storage, organized into buckets of objects. You can also configure a bucket as a static site or redirect to another URL.
Options
- You can enable versioning to make S3 keep track of all versions of an object
- You can enable logging to see all access to your bucket
- You can have different levels of access for different users
- You can set different levels of access frequency for a bucket, and different levels of redundancy
- You can encrypt your files or not
Files have to be public to be read directly by the web. You can use this to host websites, at a cost of about $0.03/GB/Month for storage and $0.09/GB/Month for transfer.
Snapshots of EBS Volumes
The goal is to take a snapshot of the EBS at a known point, then provision a new EC2 and attach that EBS in the case of a failure.
Backup:
- Stop the instance
- Elastic Block Store -> Volumes -> Create Snapshot
- Label snapshot
- Elastic Block Store -> Snapshots -> Actions -> Create Image
- Defaults are fine, but make sure to change virtualization type from paravirtual to hardware-assisted virtualization
- Restart the instance
Recovery:
- Images -> AMIs -> Launch
OS Backups
Backup:
tar czf backup.tar.gz /etc /var /home
aws s3 cp backup.tar.gz s3://BucketNameHere
Recovery:
- Dowload backup file
- Copy results over your directories
CLI
Works from local to s3, s3 to local, or between buckets
Common actions:
-
cp
-
ls
-
mv
-
rm
-
sync
-
Upload to bucket:
aws s3 cp some-local-file.md s3://bucket-name
-
List buckets:
aws s3 ls
-
List files in buckets:
aws s3 ls s3://bucket-name
-
Sync a local folder to s3:
aws s3 sync . s3://bucket-name
-
Sync bucket to local folder:
aws s3 sync local-file
--delete
flag deletes stuff that's in the destination but not in the source