60 likes | 71 Views
Sometimes you may need to copy files from Linux to S3 bucket. Here are the steps to do so.<br><br>Visit https://fedingo.com/how-to-copy-files-from-linux-to-s3-bucket/
E N D
Install AWSCLI AWSCLI is available in almost every default Linux repository. So you can easily install it with the following commands, depending on your Linux distribution. $ sudo dnf install awscli ## Fedora, Redhat and CentOS $ sudo apt install awscli ## Ubuntu, Debian and Linux Mint Run the following command to verify installation. $ aws --version
Copy Files from Linux to S3 Bucket Once AWS CLI is installed on your system, you can run the following command to list the contents of specific S3 bucket. $ aws s3 ls s3://<S3bucketName> Here is the command to copy file from your EC2 Instance’s Linux system to Amazon S3 bucket. $ aws s3 cp /full/path/to/file s3://<S3BucketName> This will copy the file to the root folder of your S3 bucket.
Copy Files from Amazon S3 bucket to Linux If you want to copy files from Amazon S3 bucket to Linux, swap the path to file and Amazon S3 bucket in the above commands. # To copy the files from S3 to EC2 $ aws s3 cp s3://<S3BucketName>/filename /full/path/to/file Similarly, if you want to copy file from a subfolder in your S3 bucket, mention the subfolder after S3 bucket name. $ aws s3 cp s3://<S3BucketName>/data/filename /full/path/to/file
Create Shell Scripts You can also add the above commands in a shell script to automate tasks. Replace S3_BUCKET_NAME and BACKUP_FILENAME with the name of Amazon S3 bucket and full path of file to be uploaded respectively. #/usr/bin/env bash S3_BUCKET_NAME="" BACKUP_FILENAME='/home/ubuntu/data.txt' ${AWSCMD} cp /tmp/${BACKUP_FILENAME} s3://${S3_BUCKET_NAME}/ if [ $? -eq 0 ]; then echo "File successfully uploaded to s3 bucket" else echo "Error in s3 upload" fi
Thank You Visit for details https://fedingo.com/how-to-copy-files-from-linux-to-s3-bucket/