Browse Source

+ sync script for wp uploads

master
dimti 5 months ago
parent
commit
51c4dc0b8b
  1. 13
      quick/settings.sh.example
  2. 27
      quick/sync/sync-uploads-from-prod-to-local.sh.example

13
quick/settings.sh.example

@ -1,10 +1,10 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SETTINGS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TMP_DIR=$SCRIPT_DIR/tmp
export TMP_DIR=$SETTINGS_SCRIPT_DIR/tmp
export PROJECT_NAME=wpstudio
export PROJECT_WEB_ROOT="${SCRIPT_DIR}/.."
export PROJECT_WEB_ROOT="${SETTINGS_SCRIPT_DIR}/.."
export TABLE_PREFIX="wp_"
@ -12,3 +12,10 @@ export PROD_DOMAIN=wpstudio.ru
export LOCAL_DOMAIN=wpstudio.local.wpstudio.ru
export THEME=nicol
export SSH_PORT=22
export SSH_PROD_USERNAME=wpstudio
export SSH_PROD_SERVER=wpstudio.ru
export REMOTE_SITE_DIR=/var/www/html

27
quick/sync/sync-uploads-from-prod-to-local.sh.example

@ -0,0 +1,27 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${SCRIPT_DIR}/../settings.sh" || {
echo "no settings" && exit 1
}
UPLOAD_DIR="wp-content/uploads"
SOURCE_UPLOADS_PATH="${REMOTE_SITE_DIR}/${UPLOAD_DIR}"
DESTINATION_UPLOADS_PATH=$(realpath "${SCRIPT_DIR}/../../${UPLOAD_DIR}")
if [ -z "$DESTINATION_UPLOADS_PATH" ]; then
echo "DESTINATION_UPLOADS_PATH is empty" && exit 1
fi
CMD="rsync -a --info=progress2 $SSH_PROD_USERNAME@$SSH_PROD_SERVER:$SOURCE_UPLOADS_PATH/ $DESTINATION_UPLOADS_PATH/"
# shellcheck disable=SC2145
echo "Execute: ${CMD}"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
/bin/bash -c "${CMD}"
fi
Loading…
Cancel
Save