vault: offline backup script (pull accounts + worlds to local snapshots)
The vault's user data (argon2 hashes + saved worlds) only lives on the VPS and isn't in git. backup.sh pulls /opt/mrpgi-vault/data down as a timestamped tarball, keeps the 30 newest, and documents the restore path in its header. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
e9cf00e686
commit
24f812dbfd
34
mrpgi-vault/backup.sh
Executable file
34
mrpgi-vault/backup.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Offline backup of the live MRPGI vault — the accounts (argon2 hashes) and
|
||||||
|
# saved worlds that ONLY exist on the dealgod VPS and are NOT in git.
|
||||||
|
#
|
||||||
|
# Pulls /opt/mrpgi-vault/data down to this machine as a timestamped tarball,
|
||||||
|
# keeping the 30 most recent snapshots. Run it from anywhere.
|
||||||
|
#
|
||||||
|
# ./mrpgi-vault/backup.sh
|
||||||
|
# MRPGI_BACKUP_DIR=/some/where ./mrpgi-vault/backup.sh # override location
|
||||||
|
#
|
||||||
|
# Restore onto the VPS (if the box is ever rebuilt):
|
||||||
|
# tar -xzf vault-YYYYMMDD-HHMMSS.tar.gz # gives ./data
|
||||||
|
# scp -r data root@100.94.195.115:/opt/mrpgi-vault/
|
||||||
|
# ssh root@100.94.195.115 'docker restart mrpgi-vault'
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REMOTE="${MRPGI_VAULT_REMOTE:-root@100.94.195.115:/opt/mrpgi-vault/data}"
|
||||||
|
DEST="${MRPGI_BACKUP_DIR:-$HOME/MRPGI-vault-backups}"
|
||||||
|
KEEP=30
|
||||||
|
|
||||||
|
mkdir -p "$DEST"
|
||||||
|
STAMP=$(date +%Y%m%d-%H%M%S)
|
||||||
|
TMP=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$TMP"' EXIT
|
||||||
|
|
||||||
|
scp -q -r "$REMOTE" "$TMP/data"
|
||||||
|
tar -czf "$DEST/vault-$STAMP.tar.gz" -C "$TMP" data
|
||||||
|
|
||||||
|
# prune to the newest $KEEP snapshots
|
||||||
|
ls -1t "$DEST"/vault-*.tar.gz 2>/dev/null | tail -n +$((KEEP + 1)) | while read -r old; do rm -f "$old"; done
|
||||||
|
|
||||||
|
COUNT=$(ls -1 "$DEST"/vault-*.tar.gz 2>/dev/null | wc -l | tr -d ' ')
|
||||||
|
SIZE=$(du -h "$DEST/vault-$STAMP.tar.gz" | cut -f1)
|
||||||
|
echo "backed up -> $DEST/vault-$STAMP.tar.gz ($SIZE; $COUNT snapshots kept)"
|
||||||
Loading…
Reference in New Issue
Block a user