Download AWS s3 bucket data using AWS ClI--
To download all files from an AWS S3 bucket to your local computer using the
AWS CLI, you can use the `aws s3 sync` command. This command synchronizes the
contents of a bucket to a directory on your local file system. Here’s how you
can do it:
1. **Install AWS CLI**: Make sure you have the AWS CLI installed and configured
with your AWS credentials. You can install it from
[here](https://aws.amazon.com/cli/).
2. **Configure AWS CLI**: If you haven't configured your AWS CLI yet,
you can do so by running:
```bash
aws configure
```
This will prompt you to enter your AWS Access Key, Secret Access Key,
region, and output format.
3. **Download Files**: Use the following command to download all files from an
S3 bucket to a local directory. Replace `your-bucket-name` with your actual
bucket name and `local-directory` with the path to the local directory where
you want to save the files.
```bash
aws s3 sync s3://your-bucket-name local-directory
```
Here’s a complete example:
1. Open a terminal (or Command Prompt on Windows).
2. Run the following command:
```bash
aws s3 sync s3://my-example-bucket /path/to/local/directory
```
This command will recursively copy all files from the S3 bucket
`my-example-bucket` to the specified local directory.
**Optional Parameters**:
- **`--exclude`**: You can exclude specific files or directories.
```bash
aws s3 sync s3://my-example-bucket /path/to/local/directory --exclude "*.tmp"
```
- **`--include`**: You can include specific files or directories.
```bash
aws s3 sync s3://my-example-bucket /path/to/local/directory --include "*.jpg"
```
- **`--delete`**: Delete files in the destination that are not in the source.
```bash
aws s3 sync s3://my-example-bucket /path/to/local/directory --delete
```
These options allow you to customize the synchronization process as needed.
0 Comments
Post a Comment