Compare commits

...

2 Commits

Author SHA1 Message Date
8004daa9f0 add restore backup script 2025-12-19 14:50:15 +01:00
95ac54ed54 update elden ring lp backup script 2025-08-17 14:55:09 +02:00
2 changed files with 53 additions and 4 deletions

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -eo pipefail
RCLONE_CONFIG="rclone.conf"
RCLONE_TARGET="minecraft:"
WORLDS_DIR="spigot/worlds"
WORLDS_DIR_BACKUP="$WORLDS_DIR.backup"
ARCHIVE_PREFIX="etc/mcserver/worlds"
SERVICE_NAME="spigot"
archive=$(rclone --config "$RCLONE_CONFIG" lsf "$RCLONE_TARGET" | sort --reverse | fzf --cycle)
if [[ -z $archive ]]; then
echo "error: no archive file has been selected!" >&2
exit 1
fi
target_dir=$(mktemp --directory)
target_archive="$target_dir/$archive"
echo "Downloading archive $archive to $target_archive ..."
rclone --config "$RCLONE_CONFIG" copy "$RCLONE_TARGET$archive" "$target_dir" --progress
if [[ -d $WORLDS_DIR_BACKUP ]]; then
echo "Deleting old worlds dir backup ($WORLDS_DIR_BACKUP) ..."
rm -rf "$WORLDS_DIR_BACKUP"
fi
echo "Un-zipping archive to $target_dir ..."
unzip "$target_archive" -d "$target_dir" 1>/dev/null
echo "Stopping server ..."
docker compose stop "$SERVICE_NAME"
echo "Backing up worlds dir ($WORLDS_DIR -> $WORLDS_DIR_BACKUP) ..."
mv "$WORLDS_DIR" "$WORLDS_DIR_BACKUP"
echo "Restoring world ($target_dir/$ARCHIVE_PREFIX -> $WORLDS_DIR) ..."
mv "$target_dir/$ARCHIVE_PREFIX" "$WORLDS_DIR"
echo "Re-starting server ..."
docker compose start "$SERVICE_NAME"
echo "Cleaning up ..."
rm -rf "$target_dir"

View File

@@ -2,8 +2,11 @@
# by creating a commit and pushing it.
# After that, OBS, ER Death Counter as well as Elden Ring is started if not already running.
$ER_SAVE_ID = "76561198077851234"
$OBS_PATH = "C:\Program Files\obs-studio\bin\64bit\obs64.exe"
$ERDC_PATH = "C:\Program Files (x86)\ER Death Counter\ER_DeathCounter.exe"
$ER_SAVE_ID = "76561198077851234"
$ER_LAUCH_PATH = "steam://rungameid/1245620"
$ER_PROCESS_NAME = "eldenring"
function Open-If-Not-Already {
@@ -33,6 +36,6 @@ $timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" commit --all --message "backup-${timestamp}"
git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" push origin main
Open-If-Not-Already -Path "C:\Program Files\obs-studio\bin\64bit\obs64.exe" -WorkingDirectory (Get-Item "$OBS_PATH").DirectoryName
Open-If-Not-Already -Path "C:\Program Files (x86)\ER Death Counter\ER_DeathCounter.exe"
Open-If-Not-Already -Path "steam://rungameid/1245620" -ProcessName "eldenring"
Open-If-Not-Already -Path "$OBS_PATH" -WorkingDirectory (Get-Item "$OBS_PATH").DirectoryName
Open-If-Not-Already -Path "$ERDC_PATH"
Open-If-Not-Already -Path "$ER_LAUCH_PATH" -ProcessName "$ER_PROCESS_NAME"