Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 09a9ed1

Browse files
committed
feat: add script to backup tracker DB
1 parent 4549584 commit 09a9ed1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

share/bin/tracker-db-backup.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Backup the Index SQLite database
4+
5+
# Define the directory where backups will be stored
6+
BACKUP_DIR="/home/torrust/backups"
7+
8+
# Define the SQLite database file's path
9+
DATABASE_FILE="/home/torrust/github/torrust/torrust-demo/storage/tracker/lib/database/sqlite3.db"
10+
11+
# Create a timestamped backup filename
12+
BACKUP_FILE="$BACKUP_DIR/tracker_backup_$(date +%Y-%m-%d_%H-%M-%S).db"
13+
14+
# Copy the SQLite database file to create a backup
15+
cp $DATABASE_FILE "$BACKUP_FILE"
16+
17+
# Find and remove backups older than 7 days
18+
find $BACKUP_DIR -type f -name "tracker_backup_*.db" -mtime +7 -exec rm {} \;

0 commit comments

Comments
 (0)