-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.bash
More file actions
84 lines (62 loc) · 2.05 KB
/
Copy pathbackup.bash
File metadata and controls
84 lines (62 loc) · 2.05 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# backup.bash: Pull BG3 mod project files into a single location for Git backup
# by mstephenson6 - modified by request, with logging and safety checks
# Stop the script if any command fails
set -e
# --- CONFIGURATION ---
# Set this to your mod's folder name (as it appears in BG3's project directories)
MOD_SUBDIR_NAME="DGB_Body_AkELkA_533a435e-8c13-bc21-7cfc-48c3a322e29a"
# Path to the Baldur’s Gate 3 Data directory (can be adjusted if needed)
BG3_DATA="E:/El/Games/Steam/steamapps/common/Baldurs Gate 3/Data"
# These are the standard subdirectories used for mod files
SUBDIR_LIST=(
"Projects"
"Editor/Mods"
"Mods"
"Public"
"Generated/Public"
)
# --- SAFETY CHECKS ---
# Check that MOD_SUBDIR_NAME was filled in (avoids copying from an empty string)
if [ -z "$MOD_SUBDIR_NAME" ]; then
echo "[ERROR] MOD_SUBDIR_NAME is not set in the script."
exit 1
fi
# Check that the BG3 data path exists
if [ ! -d "$BG3_DATA" ]; then
echo "[ERROR] BG3_DATA path not found: $BG3_DATA"
exit 1
fi
# --- MAIN SCRIPT ---
# Show what we're about to back up
echo "[INFO] Backing up mod: $MOD_SUBDIR_NAME"
echo "[INFO] From BG3 data folder: $BG3_DATA"
echo
# Loop through each subdirectory and copy over any mod folders that exist
for subdir in "${SUBDIR_LIST[@]}"; do
SRC="$BG3_DATA/$subdir/$MOD_SUBDIR_NAME" # Full path to source mod folder
DEST="$subdir/$MOD_SUBDIR_NAME" # Destination path for backup
# Skip if source directory doesn't exist
if [ ! -d "$SRC" ]; then
echo "[SKIP] $SRC not found"
continue
fi
echo "[COPY] $SRC -> $DEST"
# Delete existing copy if there is one
rm -rf "$DEST"
# Make sure the destination parent directory exists
mkdir -p "$(dirname "$DEST")"
# Copy the mod folder (with all contents) from BG3 data into this Git folder
cp -a "$SRC" "$DEST"
done
# --- GIT BACKUP ---
echo
echo "[INFO] Committing changes to Git"
# Stage all changes
git add --all
# Commit with timestamp message
git commit -m "Backup at $(date)"
# Push to remote repository
git push
# Done
echo "[DONE] Backup complete."