Amazon provide awscli command line tool to upload files from Linux command line to Amazon S3.
This is a python package, so you need pip installed for installing awscli, if you dont have pip installed, install it with
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" python get-pip.py
Now install awscli with
pip install awscli
To configure aswcli, you need to create a new Amazon Identity, that give you AWS Access Key ID and AWS Secret Access Key.
When creating user, give it full access to Amazon S3.
root@server2 [~]# aws configure AWS Access Key ID [None]: ANIOIOSHHWODBCYVGLCQ AWS Secret Access Key [None]: R90YcLbwwr5+54Nok6ki5oi+28D6vRQGFuUTaq1w Default region name [None]: us-west-2 Default output format [None]: root@server2 [~]#
To upload files, you need to create a S3 Bucket, in this case, i created bucket with name bkjoe.
For uploading single file, run
root@server2 [~]# aws s3 cp /home/cpmove-windowwa.tar.gz s3://bkjoe upload: ../home/cpmove-windowwa.tar.gz to s3://bkjoe/cpmove-windowwa.tar.gz root@server2 [~]#
To upload a folder and all files inside, run
root@server2 [~]# aws s3 cp /backup/deleted-on-2016-04 s3://bkjoe/deleted-on-2016-04/ --recursive upload: ../backup/deleted-on-2016-04/cpmove-blindsma.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-blindsma.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-diyshutt.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-diyshutt.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-floridab.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-floridab.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-springfi.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-springfi.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-theblin.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-theblin.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-wlndowco.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-wlndowco.tar.gz upload: ../backup/deleted-on-2016-04/cpmove-yourblin.tar.gz to s3://bkjoe/deleted-on-2016-04/cpmove-yourblin.tar.gz root@server2 [~]#
awscli can do more than S3. To find more about awscli, read