@@ -58,7 +58,19 @@ function aws_delete_objects {
5858 [[ ! -z " $LOGICAL_BACKUP_S3_ENDPOINT " ]] && args+=(" --endpoint-url=$LOGICAL_BACKUP_S3_ENDPOINT " )
5959 [[ ! -z " $LOGICAL_BACKUP_S3_REGION " ]] && args+=(" --region=$LOGICAL_BACKUP_S3_REGION " )
6060
61- aws s3api delete-objects " ${args[@]} " --delete Objects=[" $( printf {Key=%q}, " $@ " ) " ],Quiet=true
61+ local objects_json=" ["
62+ local first=true
63+ for key in " $@ " ; do
64+ if [ " $first " = true ]; then
65+ first=false
66+ else
67+ objects_json+=" ,"
68+ fi
69+ objects_json+=" {\" Key\" :\" $key \" }"
70+ done
71+ objects_json+=" ]"
72+
73+ aws s3api delete-objects " ${args[@]} " --delete " Objects=$objects_json ,Quiet=true"
6274}
6375export -f aws_delete_objects
6476
@@ -85,10 +97,7 @@ function aws_delete_outdated {
8597 [[ ! -z " $LOGICAL_BACKUP_S3_REGION " ]] && args+=(" --region=$LOGICAL_BACKUP_S3_REGION " )
8698
8799 # list objects older than the cutoff date
88- aws s3api list-objects " ${args[@]} " --query=" Contents[?LastModified<='$cutoff_date '].[Key]" > /tmp/outdated-backups
89-
90- # spare the last backup
91- sed -i ' $d' /tmp/outdated-backups
100+ aws s3api list-objects " ${args[@]} " --query=" Contents[?LastModified!=null && LastModified<='$cutoff_date '].[Key]" > /tmp/outdated-backups
92101
93102 count=$( wc -l < /tmp/outdated-backups)
94103 if [[ $count == 0 ]] ; then
@@ -136,7 +145,7 @@ function gcs_upload {
136145 GSUTIL_OPTIONS[1]=" GoogleCompute:service_account=default"
137146 fi
138147
139- gsutil ${GSUTIL_OPTIONS[@]} cp - " $PATH_TO_BACKUP "
148+ gsutil " ${GSUTIL_OPTIONS[@]} " cp - " $PATH_TO_BACKUP "
140149}
141150
142151function upload {
0 commit comments