Skip to content

Instantly share code, notes, and snippets.

@JMichaelRoach
Created July 28, 2015 12:35
Show Gist options
  • Select an option

  • Save JMichaelRoach/d30e605e2cfdaf0c2184 to your computer and use it in GitHub Desktop.

Select an option

Save JMichaelRoach/d30e605e2cfdaf0c2184 to your computer and use it in GitHub Desktop.
Bash script to update WordPress
#!/bin/bash
cd $1
if [ -f 'wp-config.php' ] && [ -d 'wp-admin' ] && [ 'wp-includes' ];
then
rm -rf ./wp-admin
rm -rf ./wp-includes
cp -rf /var/www/wordpress/* .
git add -u
git commit -m "WordPress updates"
else
pwd
echo "This doesn't appear to be a valid WordPress instance"
fi
@JMichaelRoach

Copy link
Copy Markdown
Author

For safety, there are two requirements:

  • must specify a directory (use . for current directory)
  • must already be a valid WordPress instance

In addition, to reduce the presence of malware and other harmful code, please the note the wp-admin and wp-includes folder are completed removed and replaced.

Also, /var/www/wordpress should be a clone of WordPress on github ... use git checkout tag to ensure you're pulling the most updated version.

Finally, I recommend keeping each installation as a git repo so you can more easily track changes.

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