larry1chan@qq.com 1 год назад
Родитель
Сommit
2c8e9635bc
11 измененных файлов с 570 добавлено и 174 удалено
  1. 3 4
      .env
  2. 96 0
      backup_volumes.sh
  3. 0 61
      bak_all_vol2.sh
  4. 53 0
      bind2local.sh
  5. 0 68
      cleanup.sh
  6. 0 2
      clear_vol_files.sh
  7. 49 0
      create_vols.sh
  8. 0 39
      docker-compose.yml
  9. 75 0
      docker-compose.yml-duplicati
  10. 188 0
      docker-compose.yml.bak
  11. 106 0
      restore_volumes.sh

+ 3 - 4
.env

@@ -1,8 +1,7 @@
-#STORAGE_ROOT=/home/orbitzs/projects/nc2
-STORAGE_ROOT=/media/orbitzs/nextcloud_files/apex
+STORAGE_ROOT=/home/orbitzs/projects/nc3/nextcloud_nc2
 DATA_VOLUME_ROOT=$STORAGE_ROOT/storage
 MYSQL_ROOT_PASSWORD=2eqQ6Rqs
 MYSQL_PASSWORD=123456
-CONTAINER_NAME=nc202501
-DUPLICAT_BACKUP_LOC=/media/orbitzs/nextcloud_files/backup/nc2/duplicati/backups
+CONTAINER_NAME=nc3
+DUPLICATI_BACKUP_LOC=/media/orbitzs/nextcloud_files/backup/nc2/duplicati/backups
 NEXTCLOUD_HOST=https://1984.algometic.com

+ 96 - 0
backup_volumes.sh

@@ -0,0 +1,96 @@
+#!/bin/bash
+#
+# Docker Volume Backup Script
+#
+# This script is designed to back up Docker volumes to a specified directory. 
+# It checks if each volume is empty before attempting to back it up and creates 
+# compressed .tar.bz2 backup files for non-empty volumes.
+#
+#  Prerequisites
+#
+#    Docker: Ensure Docker is installed and running on your system.
+#    Bash: This script is written in Bash and should be run in a Bash-compatible shell.
+#    Backup Directory: Ensure the backup directory specified in the script exists or is writable.
+#
+#Script Overview
+#
+#The script performs the following tasks:
+#
+#    Defines Variables:
+#        BACKUP_DIR: The directory where backup files will be stored.
+#        TIMESTAMP: A timestamp used to uniquely identify backup files.
+#        VOLUMES: An array of Docker volume names to back up.
+#
+#    Checks for Empty Volumes:
+#        The script uses a temporary Docker container to check if a volume is empty. If a volume is empty, it skips the backup for that volume.
+#
+#    Backs Up Volumes:
+#        For each non-empty volume, the script creates a compressed .tar.bz2 backup file in the specified backup directory.
+#        The backup is performed using the loomchild/volume-backup Docker image.
+#
+#    Verifies Backup Success:
+#        After each backup, the script checks if the backup was successful. If any backup fails, the script exits with an error.
+#
+#    Outputs Status:
+#        The script provides status messages for each step, including skipped volumes, successful backups, and any errors encountered.
+#
+
+# Variables
+BACKUP_DIR="/media/orbitzs/nextcloud_files/backup/nc2/docker_volumes"  # Change this to your desired backup directory
+TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
+
+# List of volumes to backup
+VOLUMES=("nc3_files" "nc3_oo_data" "nc3_es_index" "nc3_db" "nc3_clamav")  # Replace with your volume names
+#VOLUMES=("nc3_redis" "nc3_oo_data" "nc3_es_index"  "nc3_clamav")  # Replace with your volume names
+
+# Ensure backup directory exists
+mkdir -p "$BACKUP_DIR"
+
+# Function to check if a volume is empty
+is_volume_empty() {
+  local volume_name=$1
+
+  # Use a temporary container to check if the volume is empty
+  if docker run --rm -v "$volume_name:/volume" alpine sh -c '[ -z "$(ls -A /volume)" ]'; then
+    return 0  # Volume is empty
+  else
+    return 1  # Volume is not empty
+  fi
+}
+
+
+
+# Loop through each volume and perform the backup
+for volume in "${VOLUMES[@]}"; do
+
+  # Check if the volume is empty
+  if is_volume_empty "$volume"; then
+    echo "Skipping empty volume: $volume"
+    continue
+  fi
+
+
+  # Define the backup file name
+  
+  BACKUP_FILE="$BACKUP_DIR/${volume}_backup-${TIMESTAMP}.tar.bz2"
+  # Create a temporary container to backup the volume
+  echo "Backing up volume: $volume to $BACKUP_FILE"
+  # docker run --rm \
+  #  -v "$BACKUP_DIR:/backup" \
+  #  -v "$volume:/volume" \
+  #  alpine tar czf "/backup/${volume}_backup_${sequence}_${TIMESTAMP}.tar.bz2" -C / volume
+  docker run -v "$volume:/volume" -v "$BACKUP_DIR:/backup" --rm loomchild/volume-backup  backup -v ${volume}_backup-${TIMESTAMP} 
+
+
+
+  # Check if the backup was successful
+  if [ $? -eq 0 ]; then
+    echo "Backup completed successfully: $BACKUP_FILE"
+  else
+    echo "Backup failed for volume: $volume!"
+    exit 1
+  fi
+done
+
+echo "All backups completed successfully!"
+

+ 0 - 61
bak_all_vol2.sh

@@ -1,61 +0,0 @@
-#!/bin/bash
-
-# Variables
-BACKUP_DIR="/media/orbitzs/nextcloud_files/backup/nc2/docker_volumes"  # Change this to your desired backup directory
-TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
-
-# List of volumes to backup
-VOLUMES=("nc202501_redis" "nc202501_oo_data" "nc202501_es_root" "nc202501_es_index" "nc202501_db" "nc202501_clamav")  # Replace with your volume names
-#VOLUMES=("nc202501_redis" "nc202501_oo_data" "nc202501_es_index"  "nc202501_clamav")  # Replace with your volume names
-
-# Ensure backup directory exists
-mkdir -p "$BACKUP_DIR"
-
-# Function to check if a volume is empty
-is_volume_empty() {
-  local volume_name=$1
-
-  # Use a temporary container to check if the volume is empty
-  if docker run --rm -v "$volume_name:/volume" alpine sh -c '[ -z "$(ls -A /volume)" ]'; then
-    return 0  # Volume is empty
-  else
-    return 1  # Volume is not empty
-  fi
-}
-
-
-
-# Loop through each volume and perform the backup
-for volume in "${VOLUMES[@]}"; do
-
-  # Check if the volume is empty
-  if is_volume_empty "$volume"; then
-    echo "Skipping empty volume: $volume"
-    continue
-  fi
-
-
-  # Define the backup file name
-  
-  BACKUP_FILE="$BACKUP_DIR/${volume}_backup-${TIMESTAMP}.tar.bz2"
-  # Create a temporary container to backup the volume
-  echo "Backing up volume: $volume to $BACKUP_FILE"
-  # docker run --rm \
-  #  -v "$BACKUP_DIR:/backup" \
-  #  -v "$volume:/volume" \
-  #  alpine tar czf "/backup/${volume}_backup_${sequence}_${TIMESTAMP}.tar.bz2" -C / volume
-  docker run -v "$volume:/volume" -v "$BACKUP_DIR:/backup" --rm loomchild/volume-backup  backup -v ${volume}_backup-${TIMESTAMP} 
-
-
-
-  # Check if the backup was successful
-  if [ $? -eq 0 ]; then
-    echo "Backup completed successfully: $BACKUP_FILE"
-  else
-    echo "Backup failed for volume: $volume!"
-    exit 1
-  fi
-done
-
-echo "All backups completed successfully!"
-

+ 53 - 0
bind2local.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# This Bash script is designed to transfer files from a bind-mounted directory on the host machine to a Docker volume 
+# using the local driver. It ensures that the operation is performed with root privileges and provides 
+# detailed feedback during execution.
+#
+# Purpose
+#
+# The script is useful in scenarios where you need to migrate or copy files from a 
+# local directory (bind-mounted volume) to a Docker volume. This is particularly helpful when:
+#
+#    You want to back up files from a bind-mounted volume to a Docker volume.
+#    You need to migrate data from a local directory to a Docker volume for containerized applications.
+#    You want to ensure that files retain their permissions and ownership during the transfer.
+#
+#
+#
+# Ensure the script is run as root
+if [ "$EUID" -ne 0 ]; then
+    echo "This script must be run as root. Please use sudo or run as root."
+    exit 1
+fi
+
+# Source directory (bind-mounted volume)
+SOURCE_DIR="/media/orbitzs/nextcloud_files/apex/storage/data"
+
+# Target Docker volume (local driver)
+TARGET_VOLUME="nc3_files"
+
+# Create the target volume if it doesn't exist
+if ! docker volume inspect "$TARGET_VOLUME" &> /dev/null; then
+    echo "Creating Docker volume: $TARGET_VOLUME"
+    docker volume create --driver local "$TARGET_VOLUME"
+fi
+
+# Temporary container to copy files into the target volume
+TEMP_CONTAINER="temp_container_$(date +%s)"
+
+# Start a temporary container with the target volume mounted
+docker run --rm -d \
+    --name "$TEMP_CONTAINER" \
+    -v "$TARGET_VOLUME:/target" \
+    alpine tail -f /dev/null
+
+# Copy files from the source directory to the target volume
+echo "Copying files from $SOURCE_DIR to $TARGET_VOLUME..."
+docker cp "$SOURCE_DIR/." "$TEMP_CONTAINER:/target"
+
+# Stop the temporary container
+docker stop "$TEMP_CONTAINER"
+
+echo "Files have been successfully transferred to the Docker volume: $TARGET_VOLUME" 
+

+ 0 - 68
cleanup.sh

@@ -1,68 +0,0 @@
-#!/bin/bash
-source .env
-docker-compose down
-
-purge_dir(){
-
-        rm -Rf $DATA_VOLUME_ROOT
-        mkdir $DATA_VOLUME_ROOT  
-        mkdir $DATA_VOLUME_ROOT/metadata  
-        mkdir $DATA_VOLUME_ROOT/data  
-        mkdir $DATA_VOLUME_ROOT/metadata/elastic  
-        mkdir $DATA_VOLUME_ROOT/metadata/redis  
-        mkdir $DATA_VOLUME_ROOT/metadata/clamav  
-        mkdir $DATA_VOLUME_ROOT/metadata/oo_data  
-        mkdir $DATA_VOLUME_ROOT/metadata/db  
-}
-
-clean_up(){
-	docker volume rm ${CONTAINER_NAME}_files
-	docker volume rm ${CONTAINER_NAME}_db
-	docker volume rm ${CONTAINER_NAME}_clamav 
-	docker volume rm ${CONTAINER_NAME}_oo_data 
-	docker volume rm ${CONTAINER_NAME}_redis
-  	docker volume rm ${CONTAINER_NAME}_es_index
-  	docker volume rm ${CONTAINER_NAME}_es_root
-  
-
-        if [ ! -d "$DATA_VOLUME_ROOT" ]; then
-	        # Try to create the directory
-       		mkdir -p "$DATA_VOLUME_ROOT"
-        else
-                echo "$DATA_VOLUME_ROOT already exists"
-        fi
-	#cd $DATA_VOLUME_ROOT
-	#pwd
-	#sudo rm -Rf ./data
-	#sudo rm -Rf ./metadata
-	#mkdir ./metadata
-	#mkdir ./data
-        #mkdir ./metadata/elastic
-        #mkdir ./metadata/redis
-        #mkdir ./metadata/clamav
-        #mkdir ./metadata/oo_data
-        #mkdir ./metadata/db
-
-	while true; do
-    		read -p "WARNING: Do you wish to proceed. This will ERASE all the data on $DATA_VOLUME_ROOT?" yn
-	    case $yn in
-	        [Yy]* ) purge_dir; break;;
-	        [Nn]* ) exit;;
-	        * ) echo "Please answer yes or no.";;
-	    esac
-	done
-
-
- 	docker ps
- 	docker volume ls
-}
-
-while true; do
-    read -p "Do you wish to proceed. This will ERASE all the data on $DATA_VOLUME_ROOT and remove ${CONTAINER_NAME} volumes?" yn
-    case $yn in
-        [Yy]* ) clean_up; break;;
-        [Nn]* ) exit;;
-        * ) echo "Please answer yes or no.";;
-    esac
-done
-

+ 0 - 2
clear_vol_files.sh

@@ -1,2 +0,0 @@
-docker exec -u root -it nc202501_duplicati rm -Rf /source/data/*
-docker exec -u root -it nc202501_duplicati rm -Rf /source/db/*

+ 49 - 0
create_vols.sh

@@ -0,0 +1,49 @@
+#!/bin/bash
+
+
+
+
+# Define the container prefix
+CONTAINER="nc3_"
+
+# Define the volumes to create
+VOLUMES=(
+  "db:local"
+  "files:bind:./storage/data"
+  "redis:local"
+  "es_root:local"
+  "es_index:local"
+  "oo_data:local"
+  "clamav:local"
+)
+
+# Loop through the volumes and create them
+for volume in "${VOLUMES[@]}"; do
+  # Split the volume definition into name, driver, and bind location
+  IFS=: read -r name driver bind_location <<< "$volume"
+
+  # Append the container prefix to the volume name
+  volume_name="${CONTAINER}${name}"
+
+  echo "Creating volume: $volume_name"
+
+  # Create the volume based on the driver
+  case $driver in
+    local)
+      #docker volume create "$volume_name"
+      echo $volume_name 
+      ;;
+    bind)
+      if [ -z "$bind_location" ]; then
+        echo "Error: Bind location not specified for volume: $volume_name"
+        exit 1
+      fi
+#      docker volume create --driver local --opt type=none --opt device=$bind_location --opt o=bind "$volume_name"
+      echo docker volume create --driver local --opt type=none --opt device=$bind_location --opt o=bind "$volume_name"
+      ;;
+    *)
+      echo "Error: Unknown driver: $driver for volume: $volume_name"
+      exit 1
+      ;;
+  esac
+done

+ 0 - 39
docker-compose.yml

@@ -30,11 +30,6 @@ volumes:
     name: ${CONTAINER_NAME}_es_index
     driver: local
 
-  es_root:
-    name: ${CONTAINER_NAME}_es_root
-    driver: local
-
-
   oo_data:
     name: ${CONTAINER_NAME}_oo_data
     driver: local
@@ -43,17 +38,6 @@ volumes:
     name: ${CONTAINER_NAME}_clamav
     driver: local
 
-  duplicati_backups:
-    name: ${CONTAINER_NAME}_duplicati
-    driver: local
-    driver_opts: 
-      type: volume 
-      o: 'bind'
-      device: "${DUPLICAT_BACKUP_LOC}"
-    
-
- 
-
 services:
   db:
     image: mariadb:11.4.2
@@ -124,7 +108,6 @@ services:
         hard: -1
     volumes:
       - es_index:/usr/share/elasticsearch/data
-      - es_root:/usr/share/elasticsearch
     restart: "no" 
     ports:
       - 9200:9200
@@ -153,28 +136,6 @@ services:
       - oo_data:/var/log/onlyoffice
 
 
-  duplicati:
-    container_name: ${CONTAINER_NAME}_duplicati 
-    image: duplicati/duplicati:latest
-    environment:
-      PUID: 0 
-      PGID: 0 
-      TZ: Asia/Hong_Kong
-      CLI_ARGS: "" # optional
-      SETTINGS_ENCRYPTION_KEY: "secret1234"
-      DUPLICATI__WEBSERVICE_PASSWORD: "123456" #optional
-    volumes:
-      - ./duplicati/appdata/config:/config
-      - ./duplicati/data:/data
-      - duplicati_backups:/backups
-      - db:/source/db
-      - redis:/source/redis
-      - es_index:/source/es_index 
-      - files:/source/data
-    ports:
-      - 8200:8200
-    restart: "no"
-
   go-vod:
     container_name: ${CONTAINER_NAME}_govod
     image: radialapps/go-vod

+ 75 - 0
docker-compose.yml-duplicati

@@ -0,0 +1,75 @@
+version: '3'
+
+volumes:
+
+
+  files_player1:
+    name: ${CONTAINER_NAME}_files_player1
+    driver: local
+    driver_opts:
+      type: volume
+      o: 'bind'
+      device: "/media/orbitzs/nextcloud_files/apex/player1"
+
+  files:
+    name: ${CONTAINER_NAME}_files
+    driver: local
+    driver_opts: 
+      type: volume 
+      o: 'bind'
+      device: "${DATA_VOLUME_ROOT}/data"
+  db:
+    name: ${CONTAINER_NAME}_db
+    driver: local
+
+  redis:
+    name: ${CONTAINER_NAME}_redis
+    driver: local
+
+  es_index:
+    name: ${CONTAINER_NAME}_es_index
+    driver: local
+
+  es_root:
+    name: ${CONTAINER_NAME}_es_root
+    driver: local
+
+
+  oo_data:
+    name: ${CONTAINER_NAME}_oo_data
+    driver: local
+ 
+  clamav:
+    name: ${CONTAINER_NAME}_clamav
+    driver: local
+
+  duplicati_backups:
+    name: ${CONTAINER_NAME}_duplicati
+    driver: local
+    driver_opts: 
+      type: volume 
+      o: 'bind'
+      device: "${DUPLICATI_BACKUP_LOC}"
+    
+
+ 
+
+services:
+
+
+  duplicati:
+    container_name: ${CONTAINER_NAME}_duplicati 
+    image: duplicati/duplicati:latest
+    environment:
+      PUID: 0 
+      PGID: 0 
+      TZ: Asia/Hong_Kong
+      CLI_ARGS: "" # optional
+      SETTINGS_ENCRYPTION_KEY: "secret1234"
+      DUPLICATI__WEBSERVICE_PASSWORD: "123456" #optional
+    volumes:
+      - ./duplicati/appdata/config:/config
+      - duplicati_backups:/backups
+      - files:/source/data
+    ports:
+      - 8300:8200

+ 188 - 0
docker-compose.yml.bak

@@ -0,0 +1,188 @@
+version: '3'
+
+volumes:
+
+
+  files_player1:
+    name: ${CONTAINER_NAME}_files_player1
+    driver: local
+    driver_opts:
+      type: volume
+      o: 'bind'
+      device: "/media/orbitzs/nextcloud_files/apex/player1"
+
+  files:
+    name: ${CONTAINER_NAME}_files
+    driver: local
+    driver_opts: 
+      type: volume 
+      o: 'bind'
+      device: "${DATA_VOLUME_ROOT}/data"
+  db:
+    name: ${CONTAINER_NAME}_db
+    driver: local
+
+  redis:
+    name: ${CONTAINER_NAME}_redis
+    driver: local
+
+  es_index:
+    name: ${CONTAINER_NAME}_es_index
+    driver: local
+
+  es_root:
+    name: ${CONTAINER_NAME}_es_root
+    driver: local
+
+
+  oo_data:
+    name: ${CONTAINER_NAME}_oo_data
+    driver: local
+ 
+  clamav:
+    name: ${CONTAINER_NAME}_clamav
+    driver: local
+
+  duplicati_backups:
+    name: ${CONTAINER_NAME}_duplicati
+    driver: local
+    driver_opts: 
+      type: volume 
+      o: 'bind'
+      device: "${DUPLICATI_BACKUP_LOC}"
+    
+
+ 
+
+services:
+  db:
+    image: mariadb:11.4.2
+    container_name: ${CONTAINER_NAME}_db
+    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
+    restart: "no" 
+    volumes:
+      - db:/var/lib/mysql
+    #  - db_r1:/var/lib/mysql
+    environment:
+      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
+      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
+      - MYSQL_DATABASE=nextcloud
+      - MYSQL_USER=nextcloud
+
+
+  redis:
+    image: redis:7.2.4-alpine
+    container_name: ${CONTAINER_NAME}_redis
+    restart: "no"
+    volumes:
+      - redis:/var/lib/redis
+
+
+  app:
+#    image: nextcloud:30.0.4-apache
+    image: nextcloud-ffmpeg-image:latest
+    container_name: ${CONTAINER_NAME}
+    ports:
+      - 1234:80
+    links:
+      - db
+      - redis
+    volumes:
+      - files:/var/www/html
+      - files_player1:/var/www/html/data/player1
+    restart: "no" 
+    environment:
+      - REDIS_HOST=redis
+      - REDIS_PASSWORD=
+      - PHP_MEMORY_LIMIT=1G
+      - PHP_UPLOAD_LIMIT=12G
+    devices:
+      - /dev/dri:/dev/dri # VA-API (omit for NVENC)
+
+
+  cron:
+    image: nextcloud:30.0.4-apache
+    container_name: ${CONTAINER_NAME}_cron
+    links:
+      - db
+      - redis
+    volumes:
+      - files:/var/www/html
+    restart: "no" 
+    entrypoint: /cron.sh
+
+
+  es01:
+    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.23
+    container_name: ${CONTAINER_NAME}_es 
+    environment:
+      - node.name=es01
+      - discovery.type=single-node
+    ulimits:
+      memlock:
+        soft: -1
+        hard: -1
+    volumes:
+      - es_index:/usr/share/elasticsearch/data
+      - es_root:/usr/share/elasticsearch
+    restart: "no" 
+    ports:
+      - 9200:9200
+
+
+  av:
+    container_name: ${CONTAINER_NAME}_clamav 
+    image: mkodockx/docker-clamav:alpine
+    restart: "no" 
+    ports:
+      - 3310:3310
+    volumes:
+      - clamav:/etc/clamav
+
+
+  onlyoffice:
+    container_name: ${CONTAINER_NAME}_onlyoffice
+    image: onlyoffice/documentserver:latest
+    restart: "no"
+    environment:
+      - JWT_SECRET=secret
+    ports:
+      - 9980:80
+    volumes:
+      - oo_data:/var/www/onlyoffice/Data
+      - oo_data:/var/log/onlyoffice
+
+
+  duplicati:
+    container_name: ${CONTAINER_NAME}_duplicati 
+    image: duplicati/duplicati:latest
+    environment:
+      PUID: 0 
+      PGID: 0 
+      TZ: Asia/Hong_Kong
+      CLI_ARGS: "" # optional
+      SETTINGS_ENCRYPTION_KEY: "secret1234"
+      DUPLICATI__WEBSERVICE_PASSWORD: "123456" #optional
+    volumes:
+      - ./duplicati/appdata/config:/config
+      - duplicati_backups:/backups
+      - files:/source/data
+    ports:
+      - 8200:8200
+    restart: "no"
+
+  go-vod:
+    container_name: ${CONTAINER_NAME}_govod
+    image: radialapps/go-vod
+    restart: "no" 
+    init: true
+    depends_on:
+      - app 
+    environment:
+      - NEXTCLOUD_HOST=${NEXTCLOUD_HOST}
+      # - NEXTCLOUD_ALLOW_INSECURE=1 # (self-signed certs or no HTTPS)
+      - NVIDIA_VISIBLE_DEVICES=all
+    devices:
+      - /dev/dri:/dev/dri # VA-API (omit for NVENC)
+    volumes:
+      - files:/var/www/html:ro

+ 106 - 0
restore_volumes.sh

@@ -0,0 +1,106 @@
+#!/bin/bash
+# Docker Volume Restore Script
+#
+# This script is designed to restore Docker volumes from backup files. 
+# It allows you to specify a backup directory, a timestamp for the backup files, 
+# and a list of original and new volume names. The script ensures that the number of original volumes 
+# matches the number of new volumes and provides an option for a dry-run to simulate the restore process without making any changes.
+#
+# Prerequisites
+#
+#
+#    Docker: Ensure Docker is installed and running on your system.
+#    Backup Files: The backup files should be in the specified backup directory and follow the naming convention: <volume_name>_backup-<timestamp>.tar.bz2.
+#
+# Script Variables
+#
+#    BACKUP_DIR: The directory where the backup files are stored. Update this to your desired backup directory.
+#    TIMESTAMP: The timestamp used in the backup file names. Replace this with your desired timestamp.
+#    VOLUMES: An array of original volume names that were backed up.
+#    NEW_VOLUMES: An array of new volume names to which the backups will be restored.
+#
+# Usage
+#
+#    Set Variables: Update the BACKUP_DIR, TIMESTAMP, VOLUMES, and NEW_VOLUMES variables in the script to match your environment.
+#
+#    Run the Script:
+#        To perform a dry-run (simulate the restore process without making changes):
+#
+#	./restore_volumes.sh --dry-run
+#
+#    To perform the actual restore:
+#
+#	./restore_volumes.sh
+#
+#
+
+
+# Variables
+BACKUP_DIR="/media/orbitzs/nextcloud_files/backup/nc2/docker_volumes"  # Change this to your desired backup directory
+TIMESTAMP="20250128_134937"  # Replace with your desired timestamp
+
+
+# List of volumes to restore
+VOLUME=nc3
+NEW_VOLUME=nc3
+VOLUMES=("${VOLUME}_files" "${VOLUME}_oo_data"  "${VOLUME}_es_index" "${VOLUME}_db" "${VOLUME}_clamav")  # Replace with your original volume names
+NEW_VOLUMES=(${NEW_VOLUME}_files "${NEW_VOLUME}_oo_data"  "${NEW_VOLUME}_es_index" "${NEW_VOLUME}_db" "${NEW_VOLUME}_clamav")  # Replace with your new volume names
+
+# Ensure backup directory exists
+mkdir -p "$BACKUP_DIR"
+
+# Check if the number of original volumes matches the number of new volumes
+if [ ${#VOLUMES[@]} -ne ${#NEW_VOLUMES[@]} ]; then
+  echo "Error: Number of original volumes does not match the number of new volumes!"
+  exit 1
+fi
+
+# Parse command-line options
+while [ $# -gt 0 ]; do
+  case $1 in
+    --dry-run)
+      DRY_RUN=1
+      ;;
+    *)
+      echo "Error: Unknown option: $1"
+      exit 1
+      ;;
+  esac
+  shift
+done
+
+# Loop through each volume and perform the restore
+for ((i=0; i<${#VOLUMES[@]}; i++)); do
+  # Define the backup file name
+  BACKUP_FILE="$BACKUP_DIR/${VOLUMES[$i]}_backup-${TIMESTAMP}.tar.bz2"
+
+  # Check if the backup file exists
+  if [ ! -f "$BACKUP_FILE" ]; then
+    echo "Backup file not found: $BACKUP_FILE"
+    exit 1
+  fi
+
+  # Create a new volume (only if not in dry-run mode)
+  if [ -z "$DRY_RUN" ]; then
+    docker volume create "${NEW_VOLUMES[$i]}"
+  fi
+
+  # Print a message indicating the restore operation (only if in dry-run mode)
+  if [ -n "$DRY_RUN" ]; then
+    echo "Would restore volume: ${VOLUMES[$i]} to ${NEW_VOLUMES[$i]} from $BACKUP_FILE"
+  else
+    # Create a temporary container to restore the volume
+    echo "Restoring volume: ${VOLUMES[$i]} to ${NEW_VOLUMES[$i]} from $BACKUP_FILE"
+    docker run -v "${NEW_VOLUMES[$i]}:/volume" -v "$BACKUP_DIR:/backup" --rm loomchild/volume-backup restore -v ${VOLUMES[$i]}_backup-${TIMESTAMP}
+
+    # Check if the restore was successful
+    if [ $? -eq 0 ]; then
+      echo "Restore completed successfully: ${VOLUMES[$i]} to ${NEW_VOLUMES[$i]}"
+    else
+      echo "Restore failed for volume: ${VOLUMES[$i]} to ${NEW_VOLUMES[$i]}!"
+      exit 1
+    fi
+  fi
+done
+
+echo "All restores completed successfully!"