24 lines
465 B
Bash
Executable File
24 lines
465 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [ $# -lt 1 ]; then
|
|
echo "usage: $0 <backup.db.gz|backup.db> [target_db_path]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SRC=$1
|
|
TARGET=${2:-/root/.openclaw/workspace/asset-tracker/data/asset-tracker.db}
|
|
TMP=$(mktemp -d)
|
|
trap 'rm -rf "$TMP"' EXIT
|
|
|
|
mkdir -p "$(dirname "$TARGET")"
|
|
|
|
if [[ "$SRC" == *.gz ]]; then
|
|
gunzip -c "$SRC" > "$TMP/restore.db"
|
|
else
|
|
cp "$SRC" "$TMP/restore.db"
|
|
fi
|
|
|
|
cp "$TMP/restore.db" "$TARGET"
|
|
echo "restored to: $TARGET"
|