Add sync command to aws cli script

This commit is contained in:
Arnie 2018-03-13 06:51:52 +01:00
parent aa23d37449
commit 55082bf091

View File

@ -230,6 +230,29 @@ move() {
aws s3 mv "s3://${source_dir}" "s3://${target_dir}" ${args} --recursive --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
}
move() {
local source_dir="$1"
shift
local target_dir="$1"
shift
local args="$@"
[[ ${source_dir} = "" ]] && __err "You must provide a source directory (s3) as the first parameter" && return 137
[[ ${target_dir} = "" ]] && __err "You must provide a target directory (s3) as the second parameter" && return 137
__warn "Syncing s3://${source_dir} to s3://${target_dir}"
echo "Cache expires on ${EXPIRES}"
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
${SERVICE_NAME} \
aws s3 sync "s3://${source_dir}" "s3://${target_dir}" ${args} --delete --recursive --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
}
setPermissions() {
local target_dir="$1"