Skip to content

Instantly share code, notes, and snippets.

@alanef
Created December 3, 2019 19:29
Show Gist options
  • Select an option

  • Save alanef/1a296b05319563c34e36d7c65a05022c to your computer and use it in GitHub Desktop.

Select an option

Save alanef/1a296b05319563c34e36d7c65a05022c to your computer and use it in GitHub Desktop.
#!/bin/bash
BUCKET=$1
if [ -z "$BUCKET" ]
then
echo "-bucket must be specified"
exit 1;
fi
d=`date +%Y-%m-%d`
wproot="${HOME}/public_html" # change this to your actual wordpress directory
echo "`date`" - WordPress Backup started
cd ${wproot}
wp db export --add-drop-table - > "${HOME}/tmp/wordpress-${d}.sql"
gsutil -q cp "${HOME}/tmp/wordpress-${d}.sql" gs://${BUCKET}
rm "${HOME}/tmp/wordpress-${d}.sql"
tar -czf - -C ${wproot} . > "${HOME}/tmp/wordpress-${d}.tar.gz"
gsutil -q cp "${HOME}/tmp/wordpress-${d}.tar.gz" gs://${BUCKET}
rm "${HOME}/tmp/wordpress-${d}.tar.gz"
echo "`date`" - WordPress Backup ended
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment