Compare commits
No commits in common. "5235b4c6817ed2adc4be8c9a146542fd69d20bd6" and "1e7ad4ce61c97fc767f5316ad20db20438b9a97f" have entirely different histories.
5235b4c681
...
1e7ad4ce61
87
backup.sh
87
backup.sh
|
|
@ -1,87 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# --- Configuration ---
|
|
||||||
# The name of the directory where your docker-compose.yml resides.
|
|
||||||
# Used to name the final backup file.
|
|
||||||
BACKUP_NAME="filerun_backup_$(date +%Y%m%d_%H%M%S)"
|
|
||||||
# The directory where the compressed backup file will be saved.
|
|
||||||
BACKUP_DIR="/home/Dejan/Docker/FileRun/backup" # <--- ADJUST THIS PATH
|
|
||||||
# Directory containing your docker-compose.yml (usually the current directory)
|
|
||||||
COMPOSE_DIR=$(pwd)
|
|
||||||
|
|
||||||
# Define the local directories (volumes) to be backed up
|
|
||||||
# These MUST match the host directories in your docker-compose.yml
|
|
||||||
DB_DIR="db_data"
|
|
||||||
HTML_DIR="filerun_html"
|
|
||||||
USER_DATA_DIR="user_data"
|
|
||||||
|
|
||||||
# A temporary directory to stage the files before compression
|
|
||||||
TEMP_DIR="/tmp/filerun_backup_stage"
|
|
||||||
|
|
||||||
# --- Script Start ---
|
|
||||||
|
|
||||||
echo "--- Starting FileRun Backup Process ---"
|
|
||||||
|
|
||||||
# 1. Ensure the destination backup directory exists
|
|
||||||
mkdir -p "$BACKUP_DIR"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: Could not create backup directory $BACKUP_DIR. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Stop the FileRun and MariaDB services
|
|
||||||
echo "Stopping FileRun services to ensure data integrity..."
|
|
||||||
docker compose down
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "WARNING: Docker Compose down failed. Trying to proceed, but data integrity might be compromised."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. Create the staging directory and copy essential data
|
|
||||||
echo "Creating staging area and copying data..."
|
|
||||||
rm -rf "$TEMP_DIR"
|
|
||||||
mkdir -p "$TEMP_DIR/$BACKUP_NAME"
|
|
||||||
|
|
||||||
# Copy the core application files (mainly for system/data and system config)
|
|
||||||
cp -a "$COMPOSE_DIR/$HTML_DIR" "$TEMP_DIR/$BACKUP_NAME/"
|
|
||||||
echo "-> Copied Application HTML files."
|
|
||||||
|
|
||||||
# Copy the user files (PDFs, images, documents)
|
|
||||||
cp -a "$COMPOSE_DIR/$USER_DATA_DIR" "$TEMP_DIR/$BACKUP_NAME/"
|
|
||||||
echo "-> Copied User Files (documents)."
|
|
||||||
|
|
||||||
# Copy the database files (Metadata, users, shares, etc.)
|
|
||||||
cp -a "$COMPOSE_DIR/$DB_DIR" "$TEMP_DIR/$BACKUP_NAME/"
|
|
||||||
echo "-> Copied Database files."
|
|
||||||
|
|
||||||
# 4. Exclude unnecessary large files/caches/logs from the backup
|
|
||||||
echo "Cleaning up staging area (excluding caches and logs)..."
|
|
||||||
|
|
||||||
# Exclude unnecessary MariaDB files/logs within the copied DB_DIR
|
|
||||||
find "$TEMP_DIR/$BACKUP_NAME/$DB_DIR" -type f -name "*.log" -delete
|
|
||||||
find "$TEMP_DIR/$BACKUP_NAME/$DB_DIR" -type f -name "ib_logfile*" -delete
|
|
||||||
echo "-> Removed DB logs."
|
|
||||||
|
|
||||||
# Exclude FileRun cache/logs within the copied HTML_DIR
|
|
||||||
rm -rf "$TEMP_DIR/$BACKUP_NAME/$HTML_DIR/system/cache"
|
|
||||||
rm -rf "$TEMP_DIR/$BACKUP_NAME/$HTML_DIR/system/logs"
|
|
||||||
echo "-> Removed FileRun caches and logs."
|
|
||||||
|
|
||||||
# 5. Compress the staged data
|
|
||||||
echo "Compressing files into $BACKUP_NAME.tar.gz..."
|
|
||||||
tar -czf "$BACKUP_DIR/$BACKUP_NAME.tar.gz" -C "$TEMP_DIR" "$BACKUP_NAME"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: Compression failed. Exiting."
|
|
||||||
docker compose up -d # Try to restart services on failure
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 6. Cleanup and Restart
|
|
||||||
echo "Cleaning up staging area and temporary files..."
|
|
||||||
rm -rf "$TEMP_DIR"
|
|
||||||
|
|
||||||
echo "Starting FileRun services back up..."
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
echo "--- Backup Complete! ---"
|
|
||||||
echo "Backup file saved to: $BACKUP_DIR/$BACKUP_NAME.tar.gz"
|
|
||||||
echo "--------------------------"
|
|
||||||
|
|
@ -5,13 +5,14 @@ services:
|
||||||
image: mariadb:10.11
|
image: mariadb:10.11
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
# --- REPLACE THESE SECRETS ---
|
# --- CHANGE THESE SECRETS ---
|
||||||
MYSQL_ROOT_PASSWORD: your_very_strong_root_password
|
MYSQL_ROOT_PASSWORD: your_very_strong_root_password
|
||||||
MYSQL_DATABASE: filerun
|
MYSQL_DATABASE: filerun
|
||||||
MYSQL_USER: filerun
|
MYSQL_USER: filerun
|
||||||
MYSQL_PASSWORD: your_very_strong_filerun_password
|
MYSQL_PASSWORD: your_very_strong_filerun_password
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
volumes:
|
volumes:
|
||||||
|
# Maps the 'db_data' folder on your host machine to the MariaDB data directory.
|
||||||
- ./db_data:/var/lib/mysql
|
- ./db_data:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
|
@ -25,14 +26,16 @@ services:
|
||||||
FR_DB_PORT: 3306
|
FR_DB_PORT: 3306
|
||||||
FR_DB_NAME: filerun
|
FR_DB_NAME: filerun
|
||||||
FR_DB_USER: filerun
|
FR_DB_USER: filerun
|
||||||
# --- REPLACE THIS SECRET ---
|
# --- CHANGE THIS SECRET ---
|
||||||
FR_DB_PASS: your_very_strong_filerun_password
|
FR_DB_PASS: your_very_strong_filerun_password
|
||||||
# --------------------------
|
# --------------------------
|
||||||
APACHE_RUN_USER: www-data
|
APACHE_RUN_USER: www-data
|
||||||
APACHE_RUN_GROUP: www-data
|
APACHE_RUN_GROUP: www-data
|
||||||
volumes:
|
volumes:
|
||||||
|
# Maps the 'filerun_html' folder on your host machine for the application files.
|
||||||
- ./filerun_html:/var/www/html
|
- ./filerun_html:/var/www/html
|
||||||
- ./user_data:/user-files
|
# Maps the 'user_data' folder on your host machine for actual user files.
|
||||||
|
- ./user_data:/user-files
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
- traefik_default # Connect to your existing Traefik network
|
- traefik_default # Connect to your existing Traefik network
|
||||||
|
|
@ -41,26 +44,21 @@ services:
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
|
|
||||||
# --- CRITICAL: FILE-RUN HTTPS MIDDLEWARE ---
|
# HTTP → HTTPS redirect
|
||||||
# This middleware is vital for FileRun to correctly detect HTTPS when behind Traefik.
|
|
||||||
- "traefik.http.middlewares.filerun-headers.headers.customresponseheaders.X-Forwarded-Proto=https"
|
|
||||||
|
|
||||||
# --- HTTP (Port 80) Router: Redirect to HTTPS ---
|
|
||||||
- "traefik.http.routers.filerun-http.entrypoints=web"
|
- "traefik.http.routers.filerun-http.entrypoints=web"
|
||||||
- "traefik.http.routers.filerun-http.rule=Host(`filerun.rozic-dev.com`)"
|
- "traefik.http.routers.filerun-http.rule=Host(`filerun.rozic-dev.com`)"
|
||||||
- "traefik.http.routers.filerun-http.middlewares=redirect-to-https@docker" # Assumes a global Traefik redirect middleware
|
- "traefik.http.routers.filerun-http.middlewares=redirect-to-https"
|
||||||
|
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
|
||||||
|
|
||||||
# --- HTTPS (Port 443) Router ---
|
# HTTPS router
|
||||||
- "traefik.http.routers.filerun-https.entrypoints=websecure"
|
- "traefik.http.routers.filerun-https.entrypoints=websecure"
|
||||||
- "traefik.http.routers.filerun-https.rule=Host(`filerun.rozic-dev.com`)"
|
- "traefik.http.routers.filerun-https.rule=Host(`filerun.rozic-dev.com`)"
|
||||||
- "traefik.http.routers.filerun-https.tls=true"
|
- "traefik.http.routers.filerun-https.tls=true"
|
||||||
- "traefik.http.routers.filerun-https.tls.certresolver=letsencrypt"
|
- "traefik.http.routers.filerun-https.tls.certresolver=letsencrypt"
|
||||||
- "traefik.http.routers.filerun-https.middlewares=filerun-headers@docker" # Apply the X-Forwarded-Proto header
|
|
||||||
- "traefik.http.routers.filerun-https.priority=100" # Optional: higher priority
|
- "traefik.http.routers.filerun-https.priority=100" # Optional: higher priority
|
||||||
|
|
||||||
# --- Service Definition ---
|
# Service definition
|
||||||
- "traefik.http.services.filerun.loadbalancer.server.port=80"
|
- "traefik.http.services.filerun.loadbalancer.server.port=80"
|
||||||
# IMPORTANT: Since Traefik is handling traffic, DO NOT include a 'ports' section here.
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
internal:
|
internal:
|
||||||
|
|
|
||||||
97
restore.sh
97
restore.sh
|
|
@ -1,97 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# --- Configuration ---
|
|
||||||
# Directory containing your docker-compose.yml
|
|
||||||
COMPOSE_DIR=$(pwd)
|
|
||||||
# The directory where your compressed backup file is located (MUST match backup.sh)
|
|
||||||
BACKUP_DIR="/home/Dejan/backups/filerun" # <--- ADJUST THIS PATH
|
|
||||||
# A temporary directory to extract the backup files
|
|
||||||
TEMP_DIR="/tmp/filerun_restore_stage"
|
|
||||||
|
|
||||||
# Define the local directories (volumes)
|
|
||||||
DB_DIR="db_data"
|
|
||||||
HTML_DIR="filerun_html"
|
|
||||||
USER_DATA_DIR="user_data"
|
|
||||||
|
|
||||||
# --- Script Start ---
|
|
||||||
|
|
||||||
echo "--- Starting FileRun Restore Process ---"
|
|
||||||
|
|
||||||
# 1. Ask the user for the backup file name
|
|
||||||
echo "Available backups in $BACKUP_DIR:"
|
|
||||||
ls -1 "$BACKUP_DIR"/*.tar.gz
|
|
||||||
echo "-----------------------------------"
|
|
||||||
read -p "Enter the FULL name of the backup file (e.g., filerun_backup_20251129_174239.tar.gz): " BACKUP_FILE
|
|
||||||
|
|
||||||
FULL_BACKUP_PATH="$BACKUP_DIR/$BACKUP_FILE"
|
|
||||||
|
|
||||||
# 2. Validate the backup file
|
|
||||||
if [ ! -f "$FULL_BACKUP_PATH" ]; then
|
|
||||||
echo "ERROR: Backup file not found at $FULL_BACKUP_PATH. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. Stop the FileRun and MariaDB services
|
|
||||||
echo "Stopping FileRun services..."
|
|
||||||
docker compose down
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: Docker Compose down failed. Cannot continue restoration. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4. Clean up current volume data (IMPORTANT: irreversible step)
|
|
||||||
read -p "WARNING: This will DELETE all current data in your $DB_DIR, $HTML_DIR, and $USER_DATA_DIR directories. Continue? (y/N): " CONFIRM_DELETE
|
|
||||||
if [[ "$CONFIRM_DELETE" != "y" ]]; then
|
|
||||||
echo "Restore cancelled by user. Restarting services..."
|
|
||||||
docker compose up -d
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Deleting current data..."
|
|
||||||
rm -rf "$COMPOSE_DIR/$DB_DIR"
|
|
||||||
rm -rf "$COMPOSE_DIR/$HTML_DIR"/*
|
|
||||||
rm -rf "$COMPOSE_DIR/$USER_DATA_DIR"/*
|
|
||||||
|
|
||||||
# Recreate essential directories (in case they were fully deleted)
|
|
||||||
mkdir -p "$COMPOSE_DIR/$DB_DIR"
|
|
||||||
mkdir -p "$COMPOSE_DIR/$HTML_DIR"
|
|
||||||
mkdir -p "$COMPOSE_DIR/$USER_DATA_DIR"
|
|
||||||
|
|
||||||
# 5. Extract the backup archive
|
|
||||||
echo "Extracting backup from $BACKUP_FILE..."
|
|
||||||
rm -rf "$TEMP_DIR"
|
|
||||||
mkdir -p "$TEMP_DIR"
|
|
||||||
|
|
||||||
# Extract the tar.gz file into the temporary directory
|
|
||||||
tar -xzf "$FULL_BACKUP_PATH" -C "$TEMP_DIR"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: Extraction failed. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine the extracted folder name (it's usually the backup name without .tar.gz)
|
|
||||||
EXTRACTED_FOLDER=$(basename "$BACKUP_FILE" .tar.gz)
|
|
||||||
|
|
||||||
# 6. Copy extracted data back to the persistent volumes
|
|
||||||
echo "Copying extracted data back to live volumes..."
|
|
||||||
# Use rsync or cp -a to copy contents, excluding the root folder itself
|
|
||||||
cp -a "$TEMP_DIR/$EXTRACTED_FOLDER/$DB_DIR/." "$COMPOSE_DIR/$DB_DIR/"
|
|
||||||
cp -a "$TEMP_DIR/$EXTRACTED_FOLDER/$HTML_DIR/." "$COMPOSE_DIR/$HTML_DIR/"
|
|
||||||
cp -a "$TEMP_DIR/$EXTRACTED_FOLDER/$USER_DATA_DIR/." "$COMPOSE_DIR/$USER_DATA_DIR/"
|
|
||||||
|
|
||||||
# 7. Set correct permissions for the restored data
|
|
||||||
echo "Setting permissions for UID/GID 33 (www-data)..."
|
|
||||||
chown -R 33:33 "$COMPOSE_DIR/$HTML_DIR"
|
|
||||||
chown -R 33:33 "$COMPOSE_DIR/$DB_DIR"
|
|
||||||
chown -R 33:33 "$COMPOSE_DIR/$USER_DATA_DIR"
|
|
||||||
|
|
||||||
# 8. Cleanup and Restart
|
|
||||||
echo "Cleaning up temporary files..."
|
|
||||||
rm -rf "$TEMP_DIR"
|
|
||||||
|
|
||||||
echo "Starting FileRun services back up..."
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
echo "--- Restore Complete! ---"
|
|
||||||
echo "FileRun should now be accessible and restored to the state of $BACKUP_FILE."
|
|
||||||
echo "-------------------------"
|
|
||||||
Loading…
Reference in a new issue