Skip to content

Instantly share code, notes, and snippets.

@TonyFNZ
Created September 26, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyFNZ/eb8233fe21ab730ccf196702fc87c72c to your computer and use it in GitHub Desktop.
Save TonyFNZ/eb8233fe21ab730ccf196702fc87c72c to your computer and use it in GitHub Desktop.
#!/bin/bash
tempdir="blog-export/"
editdomain=editor.example.com
publishdomain=blog.example.com
# fail on any errors
set -e
# clean up previous run
rm -rf $tempdir
# generate static copy of the website
wget --mirror --cut-dirs=0 -P "$tempdir" -nv -nH -np -p -k -E --reject-regex "\?p=|xmlrpc" "http://$editdomain"
# Try to clean up domain names
grep -rl "http://$editdomain" $tempdir | xargs sed -i "s@$editdomain@$publishdomain@g"
# upload static content to S3
aws s3 cp $tempdir "s3://$publishdomain" --region us-east-1 --recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment