Created
December 3, 2019 19:29
-
-
Save alanef/1a296b05319563c34e36d7c65a05022c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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