Skip to content

Instantly share code, notes, and snippets.

@giraycoskun
Last active January 12, 2026 23:50
Show Gist options
  • Select an option

  • Save giraycoskun/1aafd23f5e9cdc3af6d8cc360a040e75 to your computer and use it in GitHub Desktop.

Select an option

Save giraycoskun/1aafd23f5e9cdc3af6d8cc360a040e75 to your computer and use it in GitHub Desktop.
Booklore Service data backup script to run as crontab entry depends on myscripts project
#!/bin/bash
#crontab entry: /bin/bash /home/giraycoskun/docker/booklore/backup.sh >> /home/giraycoskun/backups/booklore_cron_log.txt 2>&1
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
echo "########################################"
echo "New Backup Process Started at $TIMESTAMP"
# --- Configuration ---
BOOKS_DIR="/home/giraycoskun/docker/booklore/books"
DATA_DIR="/home/giraycoskun/docker/booklore/data"
BACKUP_DIR="/home/giraycoskun/backups/"
BOOKS_BACKUP_NAME="booklore_books_$TIMESTAMP.tar.gz"
DATA_BACKUP_NAME="booklore_data_$TIMESTAMP.tar.gz"
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# 1. Create the compressed backup
tar -czf "$BACKUP_DIR/$BOOKS_BACKUP_NAME" -C "$BOOKS_DIR" .
tar -czf "$BACKUP_DIR/$DATA_BACKUP_NAME" -C "$DATA_DIR" .
# 2. Delete backups older than 1 day (the "previous" ones)
# This keeps your storage clean while allowing for the timestamped filenames
find "$BACKUP_DIR" -name "booklore_*.tar.gz" -type f -mtime +1 -delete
echo "Backup completed: $BOOKS_BACKUP_NAME"
echo "Backup completed: $DATA_BACKUP_NAME"
cd /home/giraycoskun/Code/myscripts/
/home/giraycoskun/.local/bin/uv run python -m myscripts notify send-to-discord --message "Backup Booklore Complete"
echo "########################################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment