AWS-CLIでAmazon S3を操作・管理する
ServerFrog Blogさんより。
以下、コマンドヘルプ(Windows版)
c:\temp>aws s3 sync help
sync
^^^^
Description
***********
Syncs directories and S3 prefixes.
Synopsis
********
sync
<LocalPath> <S3Path> or <S3Path> <LocalPath> or <S3Path> <S3Path>
[--delete]
[--exact-timestamps]
[--size-only]
[--dryrun]
[--quiet]
[--recursive]
[--include <value>]
[--exclude <value>]
[--acl <value>]
[--follow-symlinks | --no-follow-symlinks]
[--no-guess-mime-type]
[--sse]
[--storage-class <value>]
[--grants <value> [<value>...]]
[--website-redirect <value>]
[--content-type <value>]
[--cache-control <value>]
[--content-disposition <value>]
[--content-encoding <value>]
[--content-language <value>]
[--expires <value>]
[--source-region <value>]
Options
*******
"paths" (string)
"--delete" (boolean) Files that exist in the destination but not in
the source are deleted during sync.
"--exact-timestamps" (boolean) When syncing from S3 to local, same-
sized items will be ignored only when the timestamps match exactly.
The default behavior is to ignore same-sized items unless the local
version is newer than the S3 version.
"--size-only" (boolean) Makes the size of each key the only criteria
used to decide whether to sync from source to destination.
"--dryrun" (boolean) Displays the operations that would be performed
using the specified command without actually running them.
"--quiet" (boolean) Does not display the operations performed from the
specified command.
"--recursive" (boolean) Command is performed on all files or objects
under the specified directory or prefix.
"--include" (string) Don't exclude files or objects in the command
that match the specified pattern
"--exclude" (string) Exclude all files or objects from the command
that matches the specified pattern.
"--acl" (string) Sets the ACl for the object when the command is
performed. Only accepts values of "private", "public-read", "public-
read-write", "authenticated-read", "bucket-owner-read", "bucket-owner-
full-control" and "log-delivery-write".
"--follow-symlinks" | "--no-follow-symlinks" (boolean) Symbolic links
are followed only when uploading to S3 from the local filesystem. Note
that S3 does not support symbolic links, so the contents of the link
target are uploaded under the name of the link. When neither
"--follow-symlinks" nor "--no-follow-symlinks" is specifed, the
default is to follow symlinks.
"--no-guess-mime-type" (boolean) Do not try to guess the mime type for
uploaded files. By default the mime type of a file is guessed when it
is uploaded.
"--sse" (boolean) Enable Server Side Encryption of the object in S3
"--storage-class" (string) The type of storage to use for the object.
Valid choices are: STANDARD | REDUCED_REDUNDANCY. Defaults to
'STANDARD'
"--grants" (string) Grant specific permissions to individual users or
groups. You can supply a list of grants of the form:
--grants Permission=Grantee_Type=Grantee_ID [Permission=Grantee_Type=Grantee_
ID ...]
Each value contains the following elements:
* "Permission" - Specifies the granted permissions, and can be set
to read, readacl, writeacl, or full.
* "Grantee_Type" - Specifies how the grantee is to be identified,
and can be set to uri, emailaddress, or id.
* "Grantee_ID" - Specifies the grantee based on Grantee_Type.
The "Grantee_ID" value can be one of:
* **uri** - The group's URI. For more information, see Who Is a
Grantee?
* **emailaddress** - The account's email address.
* **id** - The account's canonical ID
For more information on Amazon S3 access control, see Access
Control
"--website-redirect" (string) If the bucket is configured as a
website, redirects requests for this object to another object in the
same bucket or to an external URL. Amazon S3 stores the value of this
header in the object metadata.
"--content-type" (string) Specify an explicit content type for this
operation. This value overrides any guessed mime types.
"--cache-control" (string) Specifies caching behavior along the
request/reply chain.
"--content-disposition" (string) Specifies presentational information
for the object.
"--content-encoding" (string) Specifies what content encodings have
been applied to the object and thus what decoding mechanisms must be
applied to obtain the media-type referenced by the Content-Type header
field.
"--content-language" (string) The language the content is in.
"--expires" (string) The date and time at which the object is no
longer cacheable.
"--source-region" (string) When transferring objects from an s3 bucket
to an s3 bucket, this specifies the region of the source bucket. Note
the region specified by "--region" or through configuration of the CLI
refers to the region of the destination bucket. If "--source-region"
is not specified the region of the source will be the same as the
region of the destination bucket.
Examples
********
The following "sync" command syncs objects under a specified prefix
and bucket to files in a local directory by uploading the local files
to s3. A local file will require uploading if the size of the local
file is different than the size of the s3 object, the last modified
time of the local file is newer than the last modified time of the s3
object, or the local file does not exist under the specified bucket
and prefix. In this example, the user syncs the bucket "mybucket" to
the local current directory. The local current directory contains the
files "test.txt" and "test2.txt". The bucket "mybucket" contains no
objects:
aws s3 sync . s3://mybucket
Output:
upload: test.txt to s3://mybucket/test.txt
upload: test2.txt to s3://mybucket/test2.txt
The following "sync" command syncs objects under a specified prefix
and bucket to objects under another specified prefix and bucket by
copying s3 objects. A s3 object will require copying if the sizes of
the two s3 objects differ, the last modified time of the source is
newer than the last modified time of the destination, or the s3 object
does not exist under the specified bucket and prefix destination. In
this example, the user syncs the bucket "mybucket2" to the bucket
"mybucket". The bucket "mybucket" contains the objects "test.txt" and
"test2.txt". The bucket "mybucket2" contains no objects:
aws s3 sync s3://mybucket s3://mybucket2
Output:
copy: s3://mybucket/test.txt to s3://mybucket2/test.txt
copy: s3://mybucket/test2.txt to s3://mybucket2/test2.txt
The following "sync" command syncs files in a local directory to
objects under a specified prefix and bucket by downloading s3 objects.
A s3 object will require downloading if the size of the s3 object
differs from the size of the local file, the last modified time of the
s3 object is older than the last modified time of the local file, or
the s3 object does not exist in the local directory. Take note that
when objects are downloaded from s3, the last modified time of the
local file is changed to the last modified time of the s3 object. In
this example, the user syncs the current local directory to the bucket
"mybucket". The bucket "mybucket" contains the objects "test.txt" and
"test2.txt". The current local directory has no files:
aws s3 sync s3://mybucket .
Output:
download: s3://mybucket/test.txt to test.txt
download: s3://mybucket/test2.txt to test2.txt
The following "sync" command syncs objects under a specified prefix
and bucket to files in a local directory by uploading the local files
to s3. Because the "--delete" parameter flag is thrown, any files
existing under the specified prefix and bucket but not existing in the
local directory will be deleted. In this example, the user syncs the
bucket "mybucket" to the local current directory. The local current
directory contains the files "test.txt" and "test2.txt". The bucket
"mybucket" contains the object "test3.txt":
aws s3 sync . s3://mybucket --delete
Output:
upload: test.txt to s3://mybucket/test.txt
upload: test2.txt to s3://mybucket/test2.txt
delete: s3://mybucket/test3.txt
The following "sync" command syncs objects under a specified prefix
and bucket to files in a local directory by uploading the local files
to s3. Because the "--exclude" parameter flag is thrown, all files
matching the pattern existing both in s3 and locally will be excluded
from the sync. In this example, the user syncs the bucket "mybucket"
to the local current directory. The local current directory contains
the files "test.jpg" and "test2.txt". The bucket "mybucket" contains
the object "test.jpg" of a different size than the local "test.jpg":
aws s3 sync . s3://mybucket --exclude "*.jpg"
Output:
upload: test2.txt to s3://mybucket/test2.txt
The following "sync" command syncs files under a local directory to
objects under a specified prefix and bucket by downloading the local
files to s3. This example uses the "--exclude" parameter flag to
exclude a specified directory and s3 prefix from the "sync" command.
In this example, the user syncs the local current directory to the
bucket "mybucket". The local current directory contains the files
"test.txt" and "another/test2.txt". The bucket "mybucket" contains
the objects "another/test5.txt" and "test1.txt":
aws s3 sync s3://mybucket/ . --exclude "*another/*"
Output:
download: s3://mybucket/test1.txt to test1.txt
c:\temp>
コメント