From 602e2bb32988df5bccc3cc71a0a257a6e5d31349 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Thu, 4 Sep 2025 20:32:45 +0200 Subject: [PATCH] adjust testing procedure --- TESTING.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/TESTING.md b/TESTING.md index f2d460d..ee3bbce 100644 --- a/TESTING.md +++ b/TESTING.md @@ -23,16 +23,20 @@ sleep 15 docker-compose ps ``` -### 2. Verify Services +### 3. Initialize Restic Repositories + +Before running any backup operations, you need to initialize the restic repositories: ```bash -# Check if restic server is accessible -curl -s http://localhost:8000/api/v1/repos +# Initialize repository for directory backups +RESTIC_PASSWORD="testpassword123" restic -r "rest:http://localhost:8000/test-backup" init -# Check if PostgreSQL is accessible -docker exec postgres-test psql -U testuser -d testdb -c "SELECT version();" +# Initialize repository for PostgreSQL backups +RESTIC_PASSWORD="testpassword123" restic -r "rest:http://localhost:8000/postgres-backup" init ``` +**Note**: The repositories only need to be initialized once. If you recreate the restic server container, you'll need to reinitialize the repositories. + ## Directory Backup Testing This section tests the directory backup and restore functionality. @@ -66,7 +70,7 @@ export OPERATION_MODE="backup" export BACKUP_MODE="directory" export RESTIC_PASSWORD="testpassword123" export RESTIC_REPOSITORY="rest:http://localhost:8000/test-backup" -export SOURCEDIR="/home/tbehrendt/dev/backupsidecar/test_data" +export SOURCEDIR="/tmp/test-data" export ENABLE_GOTIFY="false" # Run the backup @@ -87,11 +91,12 @@ restic -r "rest:http://localhost:8000/test-backup" ls latest --password-file <(e ```bash # Create restore directory -mkdir -p restored_data +RESTOR_DIR="/tmp/restored_data" +mkdir -p $RESTOR_DIR # Set environment variables for directory restore export OPERATION_MODE="restore" -export RESTOREDIR="/home/tbehrendt/dev/backupsidecar/restored_data" +export RESTOREDIR=$RESTOR_DIR export RESTORE_SNAPSHOT_ID="latest" # Run the restore @@ -102,7 +107,7 @@ export RESTORE_SNAPSHOT_ID="latest" ```bash # Compare original and restored directories -diff -r test_data restored_data +diff -r /tmp/test-data $RESTOR_DIR # Check file contents echo "Original file:" @@ -310,6 +315,7 @@ rm -rf test_data restored_data 2. **PostgreSQL connection failed**: Ensure the database container is fully initialized 3. **Permission denied**: Make sure the backup script is executable (`chmod +x src/backup.sh`) 4. **Restic repository not found**: Check that the repository URL is correct and the server is running +5. **Script exits early with no output**: The restic repository hasn't been initialized yet. Run the initialization commands in step 3 above. ### Debug Commands