Guest User

Untitled

a guest
Sep 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. while read row; do
  2. #echo $row
  3. file_name=$(echo $row | awk '{print $4}')
  4. #echo $file_name
  5. #test if the file is already downloaded
  6. file -E $file_name &> /dev/null
  7. LOCAL_FILE_TEST_RESULT=$?
  8. if [ $LOCAL_FILE_TEST_RESULT -eq 0 ]; then
  9. #echo "${file_name} exists locally - skipping"
  10. continue
  11. fi
  12.  
  13. # test if we can download the file
  14. bucket_path="data/Galaxy-Zoo-SDSS/COS_stamps_large/${file_name}"
  15. bucket="zooniverse-cold-storage"
  16. s3_path="s3://${bucket}/${bucket_path}"
  17. aws s3 cp --quiet $s3_path .
  18. DOWNLOAD_REQ_RESULT=$?
  19. if [ $DOWNLOAD_REQ_RESULT -eq 0 ]; then
  20. echo "downloaded ${file_name}"
  21. echo $file_name > downloaded.log
  22. else
  23. aws s3api restore-object --restore-request '{"Days":5,"GlacierJobParameters":{"Tier":"Bulk"}}' --bucket ${bucket} --key ${bucket_path}
  24. RESTORE_REQUEST_RESULT=$?
  25. if [ $RESTORE_REQUEST_RESULT -eq 0 ]; then
  26. echo "requested a restore of ${file_name}"
  27. echo $file_name > restore_requests.log
  28. else
  29. echo "failed to request restore ${file_name}"
  30. echo $file_name > failed_restores.log
  31. fi
  32. fi
  33. done <file_list.txt
Add Comment
Please, Sign In to add comment