Reputation: 15810
I'd like to sync a single file from my filesystem to s3.
Is this possible or can only directories by synced?
Upvotes: 41
Views: 24404
Reputation: 5411
Use include/exclude options for the sync-directory command:
e.g. To sync just /var/local/path/filename.xyz to S3 use:
s3 sync /var/local/path s3://bucket/path --exclude='*' --include='filename.xyz'
Upvotes: 56
Reputation: 21
Just to comment on pythonjsgeo's answer. That seems to be the right solution but make sure so execute the command without the =
symbol after the include and exclude tag. I was including the =
symbol and getting weird behavior with the sync command.
s3 sync /var/local/path s3://bucket/path --exclude '*' --include '*/filename.xyz'
Upvotes: 2
Reputation: 3263
cp
can be used to copy a single file to S3. If the filename already exists in the destination, this will replace it:
aws s3 cp local/path/to/file.js s3://bucket/path/to/file.js
Keep in mind that per the docs, sync
will only make updates to the target if there have been file changes to the source file since the last run: s3 sync updates any files that have a size or modified time that are different from files with the same name at the destination.
However, cp
will always make updates to the target regardless of whether the source file has been modified.
Reference: AWS CLI Command Reference: cp
Upvotes: 18