improve offgrid mirroring script
This commit is contained in:
parent
9d63e361b4
commit
20f31cdc13
2 changed files with 38 additions and 6 deletions
38
offgrid_pile.sh
Executable file
38
offgrid_pile.sh
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "$(date) Syncing database..."
|
||||||
|
rsync -v sdbs:/var/www/sdbs-pile/db.sqlite3 .
|
||||||
|
echo "$(date) Syncing /docs..."
|
||||||
|
rsync -vr --delete sdbs:/var/www/sdbs-pile/docs/ docs/
|
||||||
|
|
||||||
|
TMP_DIR="$(mktemp -d)"
|
||||||
|
OUT_DIR="${TMP_DIR}/sdbs_pile"
|
||||||
|
mkdir -p "${OUT_DIR}"
|
||||||
|
echo "$(date) Will backup into ${OUT_DIR}"
|
||||||
|
|
||||||
|
echo "$(date) Starting local pile server"
|
||||||
|
source .venv/bin/activate
|
||||||
|
STATIC=1 python manage.py runserver 4123 &
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
echo "$(date) Waiting for server to start up..."
|
||||||
|
while ! curl -q http://localhost:4123 2>/dev/null >&2; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$(date) Starting mirror."
|
||||||
|
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent --no-host-directories --directory-prefix="${OUT_DIR}" http://localhost:4123
|
||||||
|
|
||||||
|
echo "$(date) Mirror done, killing server."
|
||||||
|
kill "${SERVER_PID}"
|
||||||
|
|
||||||
|
echo "$(date) Compressing archive..."
|
||||||
|
7z a sdbs_pile__$(date "+%Y-%m-%d__%H%M%S").7z "${OUT_DIR}"
|
||||||
|
|
||||||
|
function finish() {
|
||||||
|
echo "$(date) Cleaning up..."
|
||||||
|
kill "${SERVER_PID}" 2>/dev/null
|
||||||
|
rm -r "${TMP_DIR}"
|
||||||
|
}
|
||||||
|
trap finish EXIT
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
rsync -vr --delete sdbs:/var/www/sdbs-pile/docs/ docs/
|
|
||||||
rsync sdbs:/var/www/sdbs-pile/db.sqlite3 .
|
|
||||||
rm -rf static_pile
|
|
||||||
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent --directory-prefix=static_pile http://localhost:4002
|
|
Loading…
Reference in a new issue