Created
December 10, 2020 07:34
-
-
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
This file contains 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/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