-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore.sh
More file actions
executable file
·41 lines (33 loc) · 1.07 KB
/
Copy pathrestore.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Ghost Machines: Restore Utility
# Restores the workspace state from a snapshot archive.
echo "------------------------------------------------"
echo " GHOST MACHINES: RESTORE"
echo "------------------------------------------------"
if [ -z "$1" ]; then
echo "Usage: ./restore.sh <snapshot_file.tar.gz>"
echo "Available snapshots:"
ls ghost_snapshot_*.tar.gz 2>/dev/null || echo " (No snapshots found)"
exit 1
fi
SNAPSHOT=$1
if [ ! -f "$SNAPSHOT" ]; then
echo "[ERROR] Snapshot file '$SNAPSHOT' not found."
exit 1
fi
read -p "[WARNING] This will overwrite your current mounts/ directory. Continue? (y/n): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Restore cancelled."
exit 0
fi
echo "[INFO] Restoring from $SNAPSHOT..."
# Remove current mounts to ensure a clean restore
rm -rf mounts/
tar -xzf "$SNAPSHOT"
if [ $? -eq 0 ]; then
echo "[SUCCESS] Workspace state restored successfully."
echo "[NOTE] Run ./start.sh to launch the environments with the restored data."
else
echo "[ERROR] Restore failed."
exit 1
fi