You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
711 B

  1. #!/bin/bash
  2. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. . "${SCRIPT_DIR}/../settings.sh" || {
  4. echo "no settings" && exit 1
  5. }
  6. UPLOAD_DIR="wp-content/uploads"
  7. SOURCE_UPLOADS_PATH="${REMOTE_SITE_DIR}/${UPLOAD_DIR}"
  8. DESTINATION_UPLOADS_PATH=$(realpath "${SCRIPT_DIR}/../../${UPLOAD_DIR}")
  9. if [ -z "$DESTINATION_UPLOADS_PATH" ]; then
  10. echo "DESTINATION_UPLOADS_PATH is empty" && exit 1
  11. fi
  12. CMD="rsync -a --info=progress2 $SSH_PROD_USERNAME@$SSH_PROD_SERVER:$SOURCE_UPLOADS_PATH/ $DESTINATION_UPLOADS_PATH/"
  13. # shellcheck disable=SC2145
  14. echo "Execute: ${CMD}"
  15. read -p "Are you sure? " -n 1 -r
  16. echo # (optional) move to a new line
  17. if [[ $REPLY =~ ^[Yy]$ ]]
  18. then
  19. /bin/bash -c "${CMD}"
  20. fi