Last active
July 21, 2018 17:15
-
-
Save brokaw/252dc5ab3675a7f58b4f1bbc0e3c372f to your computer and use it in GitHub Desktop.
script to backup wordpress
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 | |
S3BUCKET="backup.bucket.name" | |
FILENAME="sitename-wordpress" | |
BACKUP_DIR=${HOME}backup/$(date "+%Y%m%dT%H%M%S") | |
mkdir -p $BACKUP_DIR | |
wp --path=$DOCUMENT_ROOT export --dir=$BACKUP_DIR | |
wp --path=$DOCUMENT_ROOT db export ${BACKUP_DIR}/${FILENAME}-$(date "+%Y%m%dT%H%M%S").sql | |
tar -C ${DOCUMENT_ROOT}wp-content -acf ${BACKUP_DIR}/${FILENAME}-content-$(date "+%Y%m%dT%H%M%S").tgz themes uploads | |
s3cmd sync ${DOCUMENT_ROOT}wp-content/uploads s3://${S3BUCKET}/current/ | |
s3cmd sync ${DOCUMENT_ROOT}wp-content/themes s3://${S3BUCKET}/current/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment