S3 AWS CLI Commands

## How to Get S3 CLI working using 3rd Party tool ##

[root@test1 tmp]# cd /etc/yum.repos.d
[root@test1 yum.repos.d]# ls -lrt
total 16
-rw-r--r--. 1 root root 529 May 30 2012 rhel-source.repo
-rw-r--r--. 1 root root 2193 May 8 15:24 redhat-rhui.repo
-rw-r--r--. 1 root root 80 May 8 15:24 rhui-load-balancers.conf
-rw-r--r--. 1 root root 567 May 8 15:24 redhat-rhui-client-config.repo
[root@test1 yum.repos.d]# vi s3tools.repo
# Save this file to /etc/yum.repos.d on your system
# and run "yum install s3cmd"
name=Tools for managing Amazon S3 - Simple Storage Service (RHEL_6)
[root@test1 yum.repos.d]# ls -lrt
total 20
-rw-r--r--. 1 root root 529 May 30 2012 rhel-source.repo
-rw-r--r--. 1 root root 2193 May 8 15:24 redhat-rhui.repo
-rw-r--r--. 1 root root 80 May 8 15:24 rhui-load-balancers.conf
-rw-r--r--. 1 root root 567 May 8 15:24 redhat-rhui-client-config.repo
-rwxr-xr-x. 1 root root 301 Sep 26 14:57 s3tools.repo
[root@test1 yum.repos.d]# chmod 644 s3tools.repo
[root@test1 yum.repos.d]# yum install s3cmd
Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-
: manager
Updating certificate-based repositories.
Unable to read consumer identity
rhui-eu-west-1-client-config-server-6 | 2.6 kB 00:00
rhui-eu-west-1-rhel-server-releases | 3.7 kB 00:00
rhui-eu-west-1-rhel-server-releases/primary_db | 22 MB 00:00
rhui-eu-west-1-rhel-server-releases-optional | 3.5 kB 00:00
rhui-eu-west-1-rhel-server-releases-optional/primary_db | 2.4 MB 00:00
s3tools | 1.3 kB 00:00
s3tools/primary | 1.0 kB 00:00
s3tools 3/3
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package s3cmd.x86_64 0:1.0.0-4.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
s3cmd x86_64 1.0.0-4.1 s3tools 91 k
Transaction Summary
Install 1 Package(s)
Total download size: 91 k
Installed size: 296 k
Is this ok [y/N]: y
Downloading Packages:
s3cmd-1.0.0-4.1.x86_64.rpm | 91 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID e612b227: NOKEY
Retrieving key from http://s3tools.org/repo/RHEL_6/repodata/repomd.xml.key
Importing GPG key 0xE612B227:
Userid: "home:mludvig OBS Project <home:mludvig@build.opensuse.org>"
From : http://s3tools.org/repo/RHEL_6/repodata/repomd.xml.key
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : s3cmd-1.0.0-4.1.x86_64 1/1
rhui-eu-west-1-rhel-server-releases/productid | 1.7 kB 00:00
Installed products updated.
Verifying : s3cmd-1.0.0-4.1.x86_64 1/1
s3cmd.x86_64 0:1.0.0-4.1
oracle 12c Cloud DB RDBMS: env | grep LIB
#edit the setdb_<sid>.sh so the following reads:
export LD_LIBRARY_PATH=/lib64:/usr/lib64:/u01/app/oracle/product/11.2.0/db_1/lib
##Run s3cmd --configure
oracle 12c Cloud DB RDBMS: s3cmd --configure
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
Access key and Secret key are your identifiers for Amazon S3
Access Key: AKIA*****************
Secret Key: Ttq9Z9psX3l**********************
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: **********
Path to GPG program [/usr/bin/gpg]:
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can't be used if you're behind a proxy
Use HTTPS protocol [No]:
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't conect to S3 directly
HTTP Proxy server name:
New settings:
Access Key: AKIA****************
Secret Key: Ttq9Z9ps**********************
Encryption password: ****************
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0
Test access with supplied credentials? [Y/n] y
Please wait...
Success. Your access key and secret key worked fine :-)
Now verifying that encryption works...
Success. Encryption and decryption worked fine :-)
Save settings? [y/N] y
Configuration saved to '/home/oracle/.s3cfg'
##Run s3cmd ls to list all your buckets.
##Make a bucket with s3cmd mb s3://my-new-bucket-name
~$ s3cmd mb s3://logix.cz-test
Bucket 'logix.cz-test' created
##List the contents of the bucket
~$ s3cmd ls s3://logix.cz-test
Bucket 'logix.cz-test':
##Upload a file into the bucket
~$ s3cmd put addressbook.xml s3://logix.cz-test/addrbook.xml
File 'addressbook.xml' stored as s3://logix.cz-test/addrbook.xml (123456 bytes)
##Retrieve the file back and verify that its hasn't been corrupted
~$ s3cmd get s3://logix.cz-test/addrbook.xml addressbook-2.xml
Object s3://logix.cz-test/addrbook.xml saved as 'addressbook-2.xml' (123456 bytes)
~$ md5sum addressbook.xml addressbook-2.xml
39bcb6992e461b269b95b3bda303addf addressbook.xml
39bcb6992e461b269b95b3bda303addf addressbook-2.xml
##delete objects
~$ s3cmd del s3://logix.cz-test/addrbook.xml s3://logix.cz-test/storage.jpg
Object s3://logix.cz-test/addrbook.xml deleted
Object s3://logix.cz-test/storage.jpg deleted
##delete bucket
~$ s3cmd rb s3://logix.cz-test
Bucket 'logix.cz-test' removed
##copy multiple objects
~$ s3cmd put file-* s3://logix.cz-test/
File 'file-one.txt' stored as s3://logix.cz-test/file-one.txt (4 bytes)
File 'file-two.txt' stored as s3://logix.cz-test/file-two.txt (4 bytes)
~$ s3cmd put --force file-* s3://logix.cz-test/prefixed:
File 'file-one.txt' stored as s3://logix.cz-test/prefixed:file-one.txt (4 bytes)
File 'file-two.txt' stored as s3://logix.cz-test/prefixed:file-two.txt (4 bytes)