Skip to content

Instantly share code, notes, and snippets.

@alanef
Created December 4, 2019 17:54
Show Gist options
  • Select an option

  • Save alanef/4571cf10a4514425ac7f9818dd90abb5 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/4571cf10a4514425ac7f9818dd90abb5 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"
aws s3 cp "${HOME}/tmp/wordpress-${d}.sql" s3://${BUCKET}
rm "${HOME}/tmp/wordpress-${d}.sql"
tar -czf - -C ${wproot} . > "${HOME}/tmp/wordpress-${d}.tar.gz"
aws s3 cp "${HOME}/tmp/wordpress-${d}.tar.gz" s3://${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