1s3cmd(1) General Commands Manual s3cmd(1)
2
3
4
6 s3cmd - tool for managing Amazon S3 storage space and Amazon CloudFront
7 content delivery network
8
10 s3cmd [OPTIONS] COMMAND [PARAMETERS]
11
13 s3cmd is a command line client for copying files to/from Amazon S3
14 (Simple Storage Service) and performing other related tasks, for
15 instance creating and removing buckets, listing objects, etc.
16
17 s3cmd can do several actions specified by the following commands.
18
19 mb s3://BUCKET
20 Make bucket
21
22 rb s3://BUCKET
23 Remove bucket
24
25 ls [s3://BUCKET[/PREFIX]]
26 List objects or buckets
27
28 la List all object in all buckets
29
30 put FILE [FILE...] s3://BUCKET[/PREFIX]
31 Put file into bucket (i.e. upload to S3)
32
33 get s3://BUCKET/OBJECT LOCAL_FILE
34 Get file from bucket (i.e. download from S3)
35
36 del s3://BUCKET/OBJECT
37 Delete file from bucket
38
39 sync LOCAL_DIR s3://BUCKET[/PREFIX]
40 Backup a directory tree to S3
41
42 sync s3://BUCKET[/PREFIX] LOCAL_DIR
43 Restore a tree from S3 to local directory
44
45 cp s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2], mv s3://BUCKET1/OBJECT1
46 s3://BUCKET2[/OBJECT2]
47 Make a copy of a file (cp) or move a file (mv). Destination can
48 be in the same bucket with a different name or in another bucket
49 with the same or different name. Adding --acl-public will make
50 the destination object publicly accessible (see below).
51
52 setacl s3://BUCKET[/OBJECT]
53 Modify Access control list for Bucket or Files. Use with
54 --acl-public or --acl-private
55
56 info s3://BUCKET[/OBJECT]
57 Get various information about a Bucket or Object
58
59 du [s3://BUCKET[/PREFIX]]
60 Disk usage - amount of data stored in S3
61
62
63 Commands for CloudFront management
64
65 cflist List CloudFront distribution points
66
67 cfinfo [cf://DIST_ID]
68 Display CloudFront distribution point parameters
69
70 cfcreate s3://BUCKET
71 Create CloudFront distribution point
72
73 cfdelete cf://DIST_ID
74 Delete CloudFront distribution point
75
76 cfmodify cf://DIST_ID
77 Change CloudFront distribution point parameters
78
79
81 Some of the below specified options can have their default values set
82 in s3cmd config file (by default $HOME/.s3cmd). As it's a simple text
83 file feel free to open it with your favorite text editor and do any
84 changes you like.
85
86 Config file related options.
87
88 --configure
89 Invoke interactive (re)configuration tool. Don't worry, you
90 won't lose your settings on subsequent runs.
91
92 -c FILE, --config=FILE
93 Config file name. Defaults to $HOME/.s3cfg
94
95 --dump-config
96 Dump current configuration after parsing config files and com‐
97 mand line options and exit.
98
99 Options specific for file transfer commands (sync, put and get):
100
101 -n, --dry-run
102 Only show what should be uploaded or downloaded but don't actu‐
103 ally do it. May still perform S3 requests to get bucket listings
104 and other in formation though.
105
106 --delete-removed
107 Delete remote objects with no corresponding local file when
108 syncing to S3 or delete local files with no corresponding object
109 in S3 when syncing from S3.
110
111 --no-delete-removed
112 Don't delete remote objects. Default for sync command.
113
114 -p, --preserve
115 Preserve filesystem attributes (mode, ownership, timestamps).
116 Default for sync command.
117
118 --no-preserve
119 Don't store filesystem attributes with uploaded files.
120
121 --exclude GLOB
122 Exclude files matching GLOB (a.k.a. shell-style wildcard) from
123 sync. See FILE TRANSFERS section and http://s3tools.org/s3cmd-
124 sync for more information.
125
126 --exclude-from FILE
127 Same as --exclude but reads GLOBs from the given FILE instead of
128 expecting them on the command line.
129
130 --rexclude REGEXP
131 Same as --exclude but works with REGEXPs (Regular expressions).
132
133 --rexclude-from FILE
134 Same as --exclude-from but works with REGEXPs.
135
136 --include=GLOB, --include-from=FILE, --rinclude=REGEXP, --rin‐
137 clude-from=FILE
138 Filenames and paths matching GLOB or REGEXP will be included
139 even if previously excluded by one of --(r)exclude(-from) pat‐
140 terns
141
142 --continue
143 Continue getting a partially downloaded file (only for get com‐
144 mand). This comes handy once download of a large file, say an
145 ISO image, from a S3 bucket fails and a partially downloaded
146 file is left on the disk. Unfortunately put command doesn't sup‐
147 port restarting of failed upload due to Amazon S3 limitations.
148
149 --skip-existing
150 Skip over files that exist at the destination (only for get and
151 sync commands).
152
153 -m MIME/TYPE, --mime-type=MIME/TYPE
154 Default MIME-type to be set for objects stored.
155
156 -M, --guess-mime-type
157 Guess MIME‐type of files by their extension. Falls back to
158 default MIME‐Type as specified by --mime-type option
159
160 --add-header=NAME:VALUE
161 Add a given HTTP header to the upload request. Can be used mul‐
162 tiple times with different header names. For instance set
163 'Expires' or 'Cache-Control' headers (or both) using this
164 options if you like.
165
166 -P, --acl-public
167 Store objects with permissions allowing read for anyone. See
168 http://s3tools.org/s3cmd-public for details and hints for stor‐
169 ing publicly accessible files.
170
171 --acl-private
172 Store objects with default ACL allowing access for you only.
173
174 -e, --encrypt
175 Use GPG encryption to protect stored objects from unauthorized
176 access. See http://s3tools.org/s3cmd-public for details about
177 encryption.
178
179 --no-encrypt
180 Don't encrypt files.
181
182 Options for CloudFront commands:
183
184 See http://s3tools.org/s3cmd-cloudfront for more details.
185
186 --enable
187 Enable given CloudFront distribution (only for cfmodify command)
188
189 --disable
190 Enable given CloudFront distribution (only for cfmodify command)
191
192 --cf-add-cname=CNAME
193 Add given CNAME to a CloudFront distribution (only for cfcreate
194 and cfmodify commands)
195
196 --cf-remove-cname=CNAME
197 Remove given CNAME from a CloudFront distribution (only for
198 cfmodify command)
199
200 --cf-comment=COMMENT
201 Set COMMENT for a given CloudFront distribution (only for cfcre‐
202 ate and cfmodify commands)
203
204 Options common for all commands (where it makes sense indeed):
205
206 -r, --recursive
207 Recursive upload, download or removal. When used with del it can
208 remove all the files in a bucket.
209
210 -f, --force
211 Force overwrite and other dangerous operations. Can be used to
212 remove a non-empty buckets with s3cmd rb --force s3://bkt
213
214 --bucket-location=BUCKET_LOCATION
215 Specify datacentre where to create the bucket. Possible values
216 are US (default) or EU.
217
218 -H, --human-readable-sizes
219 Print sizes in human readable form.
220
221 --list-md5
222 Include MD5 sums in bucket listings (only for ls command).
223
224 --progress, --no-progress
225 Display or don't display progress meter. When running on TTY
226 (e.g. console or xterm) the default is to display progress
227 meter. If not on TTY (e.g. output is redirected somewhere or
228 running from cron) the default is to not display progress meter.
229
230 --encoding=ENCODING
231 Override autodetected terminal and filesystem encoding (charac‐
232 ter set).
233
234 -v, --verbose
235 Enable verbose output.
236
237 -d, --debug
238 Enable debug output.
239
240 -h, --help
241 Show the help message and exit
242
243 --version
244 Show s3cmd version and exit.
245
246
248 One of the most powerful commands of s3cmd is s3cmd sync used for syn‐
249 chronising complete directory trees to or from remote S3 storage. To
250 some extent s3cmd put and s3cmd get share a similar behaviour with
251 sync.
252
253 Basic usage common in backup scenarios is as simple as:
254 s3cmd sync /local/path/ s3://test-bucket/backup/
255
256 This command will find all files under /local/path directory and copy
257 them to corresponding paths under s3://test-bucket/backup on the remote
258 side. For example:
259 /local/path/file1.ext -> s3://bucket/backup/file1.ext
260 /local/path/dir123/file2.bin -> s3://bucket/backup/dir123/file2.bin
261
262 However if the local path doesn't end with a slash the last directory's
263 name is used on the remote side as well. Compare these with the previ‐
264 ous example:
265 s3cmd sync /local/path s3://test-bucket/backup/
266 will sync:
267 /local/path/file1.ext -> s3://bucket/backup/path/file1.ext
268 /local/path/dir123/file2.bin -> s3://bucket/backup/path/dir123/file2.bin
269
270 To retrieve the files back from S3 use inverted syntax:
271 s3cmd sync s3://test-bucket/backup/ /tmp/restore/
272 that will download files:
273 s3://bucket/backup/file1.ext -> /tmp/restore/file1.ext
274 s3://bucket/backup/dir123/file2.bin -> /tmp/restore/dir123/file2.bin
275
276 Without the trailing slash on source the behaviour is similar to what
277 has been demonstrated with upload:
278 s3cmd sync s3://test-bucket/backup /tmp/restore/
279 will download the files as:
280 s3://bucket/backup/file1.ext -> /tmp/restore/backup/file1.ext
281 s3://bucket/backup/dir123/file2.bin -> /tmp/restore/backup/dir123/file2.bin
282
283 All source file names, the bold ones above, are matched against exclude
284 rules and those that match are then re-checked against include rules to
285 see whether they should be excluded or kept in the source list.
286
287 For the purpose of --exclude and --include matching only the bold file
288 names above are used. For instance only path/file1.ext is tested
289 against the patterns, not /local/path/file1.ext
290
291 Both --exclude and --include work with shell-style wildcards (a.k.a.
292 GLOB). For a greater flexibility s3cmd provides Regular-expression
293 versions of the two exclude options named --rexclude and --rinclude.
294 The options with ...-from suffix (eg --rinclude-from) expect a filename
295 as an argument. Each line of such a file is treated as one pattern.
296
297 There is only one set of patterns built from all --(r)exclude(-from)
298 options and similarly for include variant. Any file excluded with eg
299 --exclude can be put back with a pattern found in --rinclude-from list.
300
301 Run s3cmd with --dry-run to verify that your rules work as expected.
302 Use together with --debug get detailed information about matching file
303 names against exclude and include rules.
304
305 For example to exclude all files with ".jpg" extension except those
306 beginning with a number use:
307
308 --exclude '*.jpg' --rinclude '[0-9].*.jpg'
309
310
312 For the most up to date list of options run s3cmd --help
313 For more info about usage, examples and other related info visit
314 project homepage at
315 http://s3tools.org
316
317
319 Written by Michal Ludvig <michal@logix.cz>
320
322 Prefered way to get support is our mailing list: s3tools-gen‐
323 eral@lists.sourceforge.net
324
326 Report bugs to s3tools-bugs@lists.sourceforge.net
327
329 Copyright © 2007,2008,2009 Michal Ludvig <http://www.logix.cz/michal>
330 This is free software. You may redistribute copies of it under the
331 terms of the GNU General Public License version 2
332 <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the
333 extent permitted by law.
334
335
336
337 s3cmd(1)