28 lines
912 B
Bash
Executable File
28 lines
912 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Extract Docker container configs and save as JSON files
|
|
DOCKER_PATH="/mnt/data/docker"
|
|
OUTPUT_DIR="./docker-configs"
|
|
|
|
# Create output directory if it doesn't exist
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Check if Docker path exists
|
|
if [ ! -d "$DOCKER_PATH" ]; then
|
|
echo "Error: Docker path $DOCKER_PATH does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
# Find all container directories and extract configs
|
|
find "$DOCKER_PATH" -maxdepth 3 -name "config.v2.json" -type f | while read -r config_file; do
|
|
# Extract container ID from path (assuming structure like /mnt/data/docker/containers/{id}/config.v2.json)
|
|
container_id=$(basename "$(dirname "$config_file")")
|
|
|
|
# Copy config to output directory with container ID as filename
|
|
cp "$config_file" "$OUTPUT_DIR/${container_id}.json"
|
|
|
|
echo "Extracted config for container: $container_id"
|
|
done
|
|
|
|
echo "Extraction complete. Configs saved to $OUTPUT_DIR/"
|