Guest User

Untitled

a guest
Mar 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script to copy a TileDB array to an S3 bucket.
  4. #
  5. # This assumes you have installed the AWS CLI and 'aws' is in your PATH.
  6. # It also assumes you have set the appropriate environment variables
  7. # containing your AWS credentials.
  8.  
  9. if [ $# -lt 2 ]; then
  10. echo "Usage: $0 <array-dir> <bucket-name>"
  11. echo "Example: $0 /path/to/tiledb_array/ my-bucket"
  12. echo "The bucket name should not have a trailing /. The 's3://' prefix is added automatically."
  13. exit 1
  14. fi
  15.  
  16. array_dir=$1
  17. bucket_name=$2
  18. array_name=`basename "${array_dir}"`
  19. # Remove ending / from array_dir
  20. array_dir=`dirname ${array_dir}`/${array_name}
  21.  
  22. echo "Syncing array..."
  23. aws s3 sync "${array_dir}" "s3://${bucket_name}/${array_name}"
  24.  
  25. echo "Adding empty directory files..."
  26. aws s3api put-object --bucket "${bucket_name}" --key "${array_name}/" --content-length 0
  27.  
  28. pushd "${array_dir}" > /dev/null
  29. for f in *; do
  30. if [ -d "${f}" ]; then
  31. aws s3api put-object --bucket "${bucket_name}" --key "${array_name}/${f}/" --content-length 0
  32. fi
  33. done
Add Comment
Please, Sign In to add comment