aws.s3 (version 0.3.12)

s3sync: S3 file sync

Description

Sync files/directories to/from S3

Usage

s3sync(files = dir(recursive = TRUE), bucket, direction = c("upload",
  "download"), verbose = TRUE, ...)

Arguments

files

A character vector specifying relative paths to files to be synchronized. The default is all files in the working directory and subdirectories.

bucket

Character string with the name of the bucket, or an object of class “s3_bucket”.

direction

A character vector specifying whether to “upload” and/or “download” files. By default, s3sync is two-way, uploading any files missing from the bucket and downloading any objects missing from the local directory.

verbose

A logical indicating whether to be verbose (the default is TRUE).

Additional arguments passed to s3HTTP.

Value

A logical.

Details

s3sync synchronizes specified files to an S3 bucket. This works best if a local directory (and its subdirectories) correspond directly to the contents of an S3 bucket. If the bucket does not exist, it is created. Similarly, if local directories do not exist (corresponding to leading portions of object keys), they are created, recursively. Object keys are generated based on files and local files are named (and organized into directories) based on object keys. A slash is interpreted as a directory level. Local objects are copied to S3 and S3 objects are copied locally. This copying is performed conditionally. Objects existing locally but not in S3 are uploaded using put_object. Objects existing in S3 but not locally, are saved using save_object. If objects exist in both places, the MD5 checksum for each is compared; when identical, no copying is performed. If the checksums differ, local files are replaced with the bucket version if the local file is older and the S3 object is replaced if the local file is newer. If checksums differ but modified times match (which seems unlikely), a warning is issued.

References

aws s3 sync command line

See Also

get_bucket, put_object, , save_object

Examples

Run this code
# NOT RUN {
  put_bucket("examplebucket")

  # sync all files in current directory to bucket (upload-only)
  s3sync(bucket = "examplebucket", direction = "upload")

  # two-way sync
  s3sync(bucket = "examplebucket")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab