rsync_until_completed.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #! /bin/bash
  2. #
  3. # rsync takes a long time and can timeout, so repeat
  4. # until it's done.
  5. #
  6. # Recommendation, in another window/screen session, run:
  7. #
  8. FOLDERS=(did-it-aws elis2-aws-pii)
  9. TARGET=AWS-Indexers
  10. SLEEPTIME=300 # Time to rest between retries
  11. FORKS=10 # Maximum number of parallel actions
  12. function join_by { local IFS="$1"; shift; echo "$*"; } # joins strings
  13. FOLDERS_SHELL=\{$(join_by , ${FOLDERS[@]})\}
  14. echo Recommendation: In another window/screen session, run:
  15. echo watch --interval=30 \"ansible $TARGET --sudo --sudo-user=splunk -m shell -a \'du --summarize -h /opt/splunk/var/lib/\{splunk,splunkcold\}/$FOLDERS_SHELL/colddb\*\'\"
  16. # Store our resullt
  17. result=1
  18. while [[ $result -ne 0 ]]
  19. do
  20. result=0
  21. for folder in "${FOLDERS[@]}"
  22. do
  23. echo Synchronizing ${folder}...
  24. time ansible-playbook rsync_colddb.yml --forks=$FORKS --extra-vars="target=$TARGET folder=${folder}"
  25. result=$((result+$?))
  26. done
  27. if [[ $result -ne 0 ]]
  28. then
  29. echo Not finished. Resting for $SLEEPTIME seconds...
  30. sleep 300
  31. fi
  32. done