s3cmd

Langue: en

Autres versions - même langue

Version: 311826 (ubuntu - 07/07/09)

Section: 1 (Commandes utilisateur)

NAME

s3cmd - tool for managing Amazon S3 storage space

SYNOPSIS

s3cmd [OPTIONS] COMMAND [PARAMETERS]

DESCRIPTION

s3cmd is a command line client for copying files to/from Amazon S3 (Simple Storage Service) and performing other related tasks, for instance creating and removing buckets, listing objects, etc.

s3cmd can do several actions specified by the following commands.

mb s3://BUCKET
Make bucket
rb s3://BUCKET
Remove bucket
ls [s3://BUCKET[/PREFIX]]
List objects or buckets
la
List all object in all buckets
put FILE [FILE...] s3://BUCKET[/PREFIX]
Put file into bucket (i.e. upload to S3)
get s3://BUCKET/OBJECT LOCAL_FILE
Get file from bucket (i.e. download from S3)
del s3://BUCKET/OBJECT
Delete file from bucket
sync LOCAL_DIR s3://BUCKET[/PREFIX]
Backup a directory tree to S3
sync s3://BUCKET[/PREFIX] LOCAL_DIR
Restore a tree from S3 to local directory
info s3://BUCKET[/OBJECT]
Get various information about a Bucket or Object
du [s3://BUCKET[/PREFIX]]
Disk usage - amount of data stored in S3

OPTIONS

Some of the below specified options can have their default values set in s3cmd config file (by default $HOME/.s3cmd). As it's a simple text file feel free to open it with your favorite text editor and do any changes you like.

Config file related options.

--configure
Invoke interactive (re)configuration tool. Don't worry, you won't lose your settings on subsequent runs.
-c FILE, --config=FILE
Config file name. Defaults to $HOME/.s3cfg
--dump-config
Dump current configuration after parsing config files and command line options and exit.

Most options can have a default value set in the above specified config file.

Options specific to sync command:

--delete-removed
Delete remote objects with no corresponding local file when syncing to S3 or delete local files with no corresponding object in S3 when syncing from S3.
--no-delete-removed
Don't delete remote objects. Default for 'sync' command.
-p, --preserve
Preserve filesystem attributes (mode, ownership, timestamps). Default for 'sync' command.
--no-preserve
Don't store filesystem attributes with uploaded files.
--exclude GLOB
Exclude files matching GLOB (a.k.a. shell-style wildcard) from sync. See SYNC COMMAND section for more information.
--exclude-from FILE
Same as --exclude but reads GLOBs from the given FILE instead of expecting them on the command line.
--rexclude REGEXP
Same as --exclude but works with REGEXPs (Regular expressions).
--rexclude-from FILE
Same as --exclude-from but works with REGEXPs.
--debug-syncmatch or --debug-exclude (alias)
Display detailed information about matching file names against exclude-rules as well as information about remote vs local filelists matching. S3cmd exits after performing the match and no actual transfer takes place.

Options common for all commands (where it makes sense indeed):

-f, --force
Force overwrite and other dangerous operations.
-P, --acl-public
Store objects with permissions allowing read for anyone.
--acl-private
Store objects with default ACL allowing access for you only.
--bucket-location=BUCKET_LOCATION
Specify datacentre where to create the bucket. Possible values are US (default) or EU.
-e, --encrypt
Use GPG encryption to protect stored objects from unauthorized access.
-m MIME/TYPE, --mime-type=MIME/TYPE
Default MIME-type to be set for objects stored.
-M, --guess-mime-type
Guess MIME-type of files by their extension. Falls back to default MIME-Type as specified by --mime-type option
-H, --human-readable-sizes
Print sizes in human readable form.
-v, --verbose
Enable verbose output.
-d, --debug
Enable debug output.
-h, --help
Show the help message and exit
--version
Show s3cmd version and exit.

SYNC COMMAND

One of the most powerful commands of s3cmd is s3cmd sync used for synchronising complete directory trees to or from remote S3 storage.

Basic usage common in backup scenarios is as simple as:

         s3cmd sync /local/path s3://test-bucket/backup
 

This command will find all files under /local/path directory and copy them to corresponding paths under s3://test-bucket/backup on the remote side. For example:

 /local/path/file1.ext         ->  s3://test-bucket/backup/file1.ext
 /local/path/dir123/file2.bin  ->  s3://test-bucket/backup/dir123/file2.bin
 

To retrieve the files back from S3 use inverted syntax:

         s3cmd sync s3://test-bucket/backup/ /tmp/restore
 
that will download files:
 s3://test-bucket/backup/file1.ext         ->  /tmp/restore/file1.ext       
 s3://test-bucket/backup/dir123/file2.bin  ->  /tmp/restore/dir123/file2.bin
 

For the purpose of --exclude and --exclude-from matching the file name always begins with / (slash) and has the local or remote common part removed. For instance in the previous example the file names tested against --exclude list will be /file1.ext and /dir123/file2.bin, that is both with the leading slash regardless whether you specified s3://test-bucket/backup or s3://test-bucket/backup/ (note the trailing slash) on the command line.

Both --exclude and --exclude-from work with shell-style wildcards (a.k.a. GLOB). For a greater flexibility s3cmd provides Regular-expression versions of the two exclude options named --rexclude and --rexclude-from.

Run s3cmd with --debug-syncmatch to get detailed information about matching file names against exclude rules.

For example to exclude all files with ".bin" extension with a REGEXP use:

       --rexclude '.bin$'

to exclude all hidden files and subdirectories (i.e. those whose name begins with dot ".") use GLOB:

       --exclude '/.*'

on the other hand to exclude only hidden files but not hidden subdirectories use REGEXP:

       --rexclude '/.[^/]*$'

etc...

AUTHOR

Written by Michal Ludvig <michal@logix.cz>

REPORTING BUGS

Report bugs to s3tools-general@lists.sourceforge.net Copyright © 2007,2008 Michal Ludvig <http://www.logix.cz/michal>
This is free software. You may redistribute copies of it under the terms of the GNU General Public License version 2 <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.

SEE ALSO

For the most up to date list of options run s3cmd --help
For more info about usage, examples and other related info visit project homepage at
http://s3tools.logix.cz