forked from tosca07/picochess
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmove-books-games-to-backup.sh
More file actions
executable file
·49 lines (41 loc) · 1.29 KB
/
Copy pathmove-books-games-to-backup.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.29 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
#!/bin/sh
# move-books-games-to-backup.sh – Move book and game resources to backup
# Run as user pi; mirrors move-engines-to-backup.sh but for books/games.
#
REPO_DIR=${REPO_DIR:-/opt/picochess}
BOOKS_DIR="$REPO_DIR/books"
GAMES_DIR="$REPO_DIR/gamesdb"
BACKUP_DIR_BASE="${HOME}/pico_backups"
BACKUP_DIR="$BACKUP_DIR_BASE/current"
BACKUP_TARGET="$BACKUP_DIR/books_games_backup"
if [ ! -d "$REPO_DIR" ]; then
echo "Repository directory $REPO_DIR not found. Aborting." >&2
exit 1
fi
mkdir -p "$BACKUP_TARGET" || {
echo "Error: Failed to create backup directory $BACKUP_TARGET" >&2
exit 1
}
echo "Backing up book resources..."
if [ -d "$BOOKS_DIR" ]; then
rm -rf "$BACKUP_TARGET/books"
mv "$BOOKS_DIR" "$BACKUP_TARGET/books" || {
echo "Error: Failed to move books directory to backup." >&2
exit 1
}
else
echo "No books directory found – skipping."
fi
echo "Backing up games database resources..."
if [ -d "$GAMES_DIR" ]; then
rm -rf "$BACKUP_TARGET/gamesdb"
mv "$GAMES_DIR" "$BACKUP_TARGET/gamesdb" || {
echo "Error: Failed to move gamesdb directory to backup." >&2
exit 1
}
else
echo "No gamesdb directory found – skipping."
fi
chown -R pi:pi "$BACKUP_TARGET" 2>/dev/null || true
echo "Books and games moved to $BACKUP_TARGET."
exit 0