Skip to content

Instantly share code, notes, and snippets.

@jbrains
Created September 14, 2014 12:34
Show Gist options
  • Save jbrains/035dd20f0f0fe64ad16b to your computer and use it in GitHub Desktop.
Save jbrains/035dd20f0f0fe64ad16b to your computer and use it in GitHub Desktop.
A safe approach to publish-on-push with git and Wordpress
#!/bin/sh
# Improved safety by not checking out directly into document root
pushd /home/jbrains
SCRATCH="$(date +%N)"
TARGET="/home/jbrains/domains/jbrains.ca/web/wordpress-jbrains.ca"
# Backup
tar cf "wordpress-jbrains.ca.$SCRATCH.tar" $TARGET
# Clone, then copy
mkdir $SCRATCH
pushd $SCRATCH
git clone /home/jbrains/domains/jbrains.ca/wordpress.git
cp -RP wordpress/* $TARGET
popd
rm -fr $SCRATCH
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment