“aws s3 mv” Command Examples

The aws s3 mv command is a part of the AWS Command Line Interface (CLI) and is used to move local files or objects stored in Amazon S3 to another location, either locally or within Amazon S3 itself.

Here’s an overview of the aws s3 mv command and its functionality:

  • Moving Local Files to S3: The aws s3 mv command allows you to upload local files or directories to Amazon S3 and move them from the local machine to the specified S3 location. This is useful when you want to transfer files to S3 and remove them from the local machine after the move.
  • Moving S3 Objects Locally: You can use the aws s3 mv command to download files or objects stored in Amazon S3 to your local machine and move them to a different local location. This is helpful when you need to transfer files from S3 to a different directory or remove them from S3 after the move.
  • Moving Within S3: The aws s3 mv command also supports moving objects within Amazon S3 itself. You can specify the source S3 bucket and key as well as the destination bucket and key, allowing you to move objects from one location to another within S3.
  • Recursive Move: The aws s3 mv command provides an option to perform a recursive move, enabling you to move entire directories or folders and their contents. This ensures that the directory structure is maintained during the move process.
  • Preserving Metadata: By default, the aws s3 mv command preserves the metadata (e.g., timestamps, permissions) of the source files or objects during the move process. This ensures that the moved files retain the same attributes as the originals.
  • Overwriting Objects: If a file or object with the same name already exists at the destination, the aws s3 mv command provides options to overwrite the existing object or skip the move operation for that specific file.

The aws s3 mv command provides a convenient and efficient way to move files and objects between your local machine and Amazon S3 or within different locations in S3 itself. It is a powerful tool for managing data transfer and organization within your S3 storage.

aws s3 mv Command Examples

1. Move a file from local to a specified bucket:

# aws s3 mv /path/to/local_file s3://bucket_name/path/to/remote_file

2. Move a specific S3 object into another bucket:

# aws s3 mv s3://bucket_name1/path/to/file s3://bucket_name2/path/to/target

3. Move a specific S3 object into another bucket keeping the original name:

# aws s3 mv s3://bucket_name1/path/to/file s3://bucket_name2

4. Display help:

# aws s3 mv help
Related Post