Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. # Script to download all RDS logs for a DB instance
  3. # requires AWS cli and jq.
  4.  
  5. DB=${1}
  6.  
  7. if [ -z ${DB} ]; then
  8. echo "Please pass an argument for the database. E.g.:"
  9. echo " ${0} my_rds_db"
  10. fi
  11.  
  12.  
  13. if [ -z ${SKIP_LOGFILES} ]; then
  14. echo "Downloading list of logfiles"
  15. aws rds describe-db-log-files --db-instance-identifier ${DB} | \
  16. jq ".DescribeDBLogFiles[].LogFileName" -r > logfiles
  17. fi
  18.  
  19. test -d logs || mkdir logs
  20.  
  21. while IFS='' read -r file; do
  22. portion="logs/$(basename ${file})"
  23.  
  24. if [ ! -f "${portion}" ]; then
  25. echo "Downloading ${file}"
  26. aws rds download-db-log-file-portion --db-instance-identifier ${DB} \
  27. --log-file-name ${file} | jq -r ".LogFileData" > ${portion}
  28. fi
  29. done < logfiles
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement