Skip to content

Commit

Permalink
Merge pull request #29 from pb82/optional-upload
Browse files Browse the repository at this point in the history
check glob before uploading
  • Loading branch information
pb82 authored Mar 12, 2019
2 parents c5a828f + e3e56b7 commit f96c935
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 0 additions & 1 deletion image/tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ else
encrypted_files="$ARCHIVES_DEST/*"
fi
upload_archive "${encrypted_files}" $DATESTAMP backups/$PRODUCT_NAME/$component
echo '==> Archive upload completed'

echo "[$DATESTAMP] Backup completed"

Expand Down
18 changes: 13 additions & 5 deletions image/tools/lib/backend/s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ function upload_archive {
local AWS_SECRET_ACCESS_KEY="$(get_s3_access_key)"

for fname in ${file_list}; do
s3cmd put --access_key ${AWS_ACCESS_KEY_ID} --secret_key ${AWS_SECRET_ACCESS_KEY} --progress ${fname} "s3://$AWS_S3_BUCKET_NAME/$bucket_folder/$datestamp/$(basename ${fname})"
rc=$?
if [[ ${rc} -ne 0 ]]; then
echo "==> Upload $fname: FAILED"
exit 1
ls ${fname}

# ls will exit with 1 if the glob does not expand to any files
if [[ $? -eq 0 ]]; then
s3cmd put --access_key ${AWS_ACCESS_KEY_ID} --secret_key ${AWS_SECRET_ACCESS_KEY} --progress ${fname} "s3://$AWS_S3_BUCKET_NAME/$bucket_folder/$datestamp/$(basename ${fname})"
rc=$?
if [[ ${rc} -ne 0 ]]; then
echo "==> Upload $fname: FAILED"
exit 1
fi
echo "==> Upload ${fname} completed"
else
echo "==> No backups in ${fname} to upload"
fi
done
}
11 changes: 8 additions & 3 deletions image/tools/lib/component/enmasse_pv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ function component_dump_data {
dump_pod_data ${pod} ${dump_dest}
done

local ts=$(date '+%H:%M:%S')
tar -zcvf "$archive_path/enmasse-pv-data-${ts}.tar.gz" -C $dump_dest .
rm -rf $dump_dest
ls ${dump_dest}/*
if [[ $? -eq 0 ]]; then
local ts=$(date '+%H:%M:%S')
tar -zcvf "$archive_path/enmasse-pv-data-${ts}.tar.gz" -C $dump_dest .
rm -rf $dump_dest
else
echo "==> no enmasse broker data to backup"
fi
}

0 comments on commit f96c935

Please sign in to comment.