Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
languages:
- en
- cs
---
# s3cmd command line tool
[S3cmd](https://s3tools.org/download) is a free command line tool. It allows you to upload and download your data to the S3 object storage. S3cmd is written in Python. S3cmd is an open-source project available under GNU Public License v2 (GPLv2) and it is free for personal as well as commercial usage.
!!! warning
We recommend you **use preferably [AWS CLI](s3cmd.md)**. We encountered some issues while using s3cmd. For instance, bucket names cannot begin with numbers or capital letters.
## Installation of s3cmd tool
S3cmd is available in the system repositories for CentOS, RHEL and Ubuntu. You can install it via following guide.
**On CentOS/RHEL**
sudo yum install s3cmd
**On Ubuntu/Debian**
sudo apt install s3cmd
## Configuration of s3cmd tool
Please insert the following lines into the config file located at **/home/user/.s3cfg**.
[default]
host_base = https://s3.clX.du.cesnet.cz
use_https = True
access_key = xxxxxxxxxxxxxxxxxxxxxx
secret_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
host_bucket = s3.clX.du.cesnet.cz
**Host base** and **Host bucket** is S3 endpoint URL, which you received via email together with **Access Key** and **Secret Key**. You should receive it via email during the S3 account creation.
**Config file with GPG encryption**
[default]
host_base = https://s3.clX.du.cesnet.cz
use_https = True
access_key = xxxxxxxxxxxxxxxxxxxxxx
secret_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
host_bucket = s3.clX.du.cesnet.cz
gpg_command = /usr/bin/gpg
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_passphrase = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
## Basic s3cmd commands
S3cmd commands support elementary operations with buckets - creation, listing, and deletion.
### Bucket operations
???+ note "Bucket name"
The bucket name should be unique within tenant and should contain only small letters, capital letters, numerals, dashes, and dots. The bucket name must begin only with a letter or numeral and it cannot contain dots next to dashes or multiple dots.
**Listing all s3 buckets**
s3cmd ls
**Creation of new s3 bucket**
s3cmd mb s3://newbucket
**Removing s3 bucket**
s3cmd rb s3://newbucket
_Only emptied bucket can be removed!_
**Listing s3 bucket size**
s3cmd s3://newbucket/ du
### Files and directories operation
**Listing of s3 bucket**
s3cmd ls s3://newbucket/
**File upload**
s3cmd put file.txt s3://newbucket/
**Upload of encrypted files**
s3cmd put -e file.txt s3://newbucket/
**Directory upload**
s3cmd put -r directory s3://newbucket/
_Please make sure, that you didn't forget to remove the trailing slash (e.g. .: directory/), trailing slash denotes uploading only the content of the desired directory._
**Download file from s3 bucket**
s3cmd get s3://newbucket/file.txt
**Data deletion from s3 bucket**
s3cmd del s3://newbucket/file.txt
s3cmd del s3://newbucket/directory
**Data sync into s3 bucket from local machine**
s3cmd sync /local/path/ s3://newbucket/backup/
**Data sync from s3 bucket to local machine**
3cmd sync s3://newbucket/backup/ ~/restore/