Skip to content

Instantly share code, notes, and snippets.

@cvn
Created December 10, 2020 07:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvn/85783bd089f486521a26dc33ac5f96c1 to your computer and use it in GitHub Desktop.
Save cvn/85783bd089f486521a26dc33ac5f96c1 to your computer and use it in GitHub Desktop.
A shell script to download a copy of your my.webfaction.com, requires wget
#!/bin/sh
if ! command -v wget &> /dev/null
then
echo "wget could not be found"
exit
fi
read -p 'Username: ' USERNAME
read -sp 'Password: ' PASSWORD
echo
echo "- Get csrftoken"
wget --keep-session-cookies \
--save-cookies=cookies-csrf.txt \
--no-verbose \
https://my.webfaction.com/
echo "- Get csrfmiddlewaretoken"
CSRFMIDDLEWARE=$(grep -o "csrf.*" index.html | cut -f3 -d\')
rm index.html
echo "- Log in"
wget --keep-session-cookies \
--load-cookies=cookies-csrf.txt \
--save-cookies=cookies-login.txt \
--post-data="csrfmiddlewaretoken=${CSRFMIDDLEWARE}&username=${USERNAME}&password=${PASSWORD}" \
--no-verbose \
https://my.webfaction.com/
rm index.html
echo "- Mirror site"
wget --mirror \
--no-parent \
--convert-links \
--adjust-extension \
--load-cookies=cookies-login.txt \
--reject-regex=logout \
--no-verbose \
https://my.webfaction.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment