Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aadilprabhakar/43ad3fe64c404bf29199dd4298b0ea3a to your computer and use it in GitHub Desktop.
Save aadilprabhakar/43ad3fe64c404bf29199dd4298b0ea3a to your computer and use it in GitHub Desktop.
RSync via SSH (Use case - push files to self-hosted CDN)
#!/bin/bash
####################################
# Rsync media to CDN
####################################
rsync -avzhe ssh /livehost/wp-content/uploads/ cdnuser@cdnhost:/cdnhost/wp-content/uploads/
rsync -avzhe ssh /livehost/wp-content/plugins/ cdnuser@cdnhost:/cdnhost/wp-content/plugins/
rsync -avzhe ssh /livehost/wp-content/themes/ cdnuser@cdnhost:/cdnhost/wp-content/themes/
rsync -avzhe ssh /livehost/wp-content/mu-plugins/ cdnuser@cdnhost:/cdnhost/wp-content/mu-plugins/
rsync -avzhe ssh /livehost/wp-includes/ cdnuser@cdnhost:/cdnhost/wp-includes/
#echo "Subject: CDN sync" | sendmail -v in.case@you.want.tobe.notified
#create log with datetime as filename
alias logname="date +%s"
touch /livehost/.synclogs/log.$(logname)
@aadilprabhakar
Copy link
Author

You do need to create and authorize your ssh key before trying to connect :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment