Skip to content

Instantly share code, notes, and snippets.

@maxfenton
Created May 7, 2026 14:08
Show Gist options
  • Select an option

  • Save maxfenton/b643d69709353d463559834118074cc9 to your computer and use it in GitHub Desktop.

Select an option

Save maxfenton/b643d69709353d463559834118074cc9 to your computer and use it in GitHub Desktop.
bin/pull-content
#!/usr/bin/env bash
# Pull content from production to local. READ-ONLY — never touches the server.
#
# Usage:
# bin/pull-content — dry run
# bin/pull-content --real — execute
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
if [ -f "$PROJECT_ROOT/.env" ]; then
source "$PROJECT_ROOT/.env"
fi
: "${DEPLOY_USER:?DEPLOY_USER not set — add to .env}"
: "${DEPLOY_HOST:?DEPLOY_HOST not set — add to .env}"
: "${PRODUCTION_PATH:?PRODUCTION_PATH not set — add to .env}"
if [[ "${1:-}" != "--real" ]]; then
echo "DRY RUN — showing what would be pulled from production (no changes made):"
echo ""
rsync -rlptzv --delete --dry-run \
"$DEPLOY_USER@$DEPLOY_HOST:$PRODUCTION_PATH/content/" \
"$PROJECT_ROOT/content/"
echo ""
echo "Run with --real to sync these changes locally."
exit 0
fi
echo "Pulling content from production..."
rsync -rlptzv --delete \
"$DEPLOY_USER@$DEPLOY_HOST:$PRODUCTION_PATH/content/" \
"$PROJECT_ROOT/content/"
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment