#!/bin/bash # Test script to verify Docker data persistence echo "๐Ÿงช Testing Capsule Docker Data Persistence..." echo "" # Ensure data directory exists mkdir -p data # Start container echo "๐Ÿ“ฆ Starting container..." docker-compose up -d # Wait for container to be ready echo "โณ Waiting for container to start..." sleep 10 # Check if container is running if ! docker-compose ps | grep -q "Up"; then echo "โŒ Container failed to start" docker-compose logs exit 1 fi echo "โœ… Container is running" echo "" # Create a test file in the data directory TEST_FILE="data/persistence-test-$(date +%s).txt" echo "test data from host" > "$TEST_FILE" echo "๐Ÿ“ Created test file: $TEST_FILE" # Check if file is visible in container echo "๐Ÿ” Checking if file is visible in container..." if docker-compose exec capsule ls -la /app/data | grep -q "persistence-test"; then echo "โœ… Test file is visible in container" else echo "โŒ Test file NOT visible in container" exit 1 fi # Restart container echo "" echo "๐Ÿ”„ Restarting container to test persistence..." docker-compose restart # Wait for restart sleep 10 # Check if file still exists after restart echo "๐Ÿ” Checking if test file persists after restart..." if [ -f "$TEST_FILE" ]; then echo "โœ… Test file persisted after container restart" else echo "โŒ Test file was lost after restart" exit 1 fi # Clean up test file rm "$TEST_FILE" echo "" echo "โœ… All persistence tests passed!" echo "" echo "Data persistence verified:" echo " - Host directory: ./data" echo " - Container directory: /app/data" echo " - Data survives container restarts: YES" echo "" echo "Your user data will be safely stored in ./data/" echo ""