SnapRAID automation tool designed for integration with *arr applications (Radarr, Sonarr, etc.). Provides automated SnapRAID operations with safety checks, notifications, and webhook support for seamless integration with media management applications.
- Safety Checks: Configurable thresholds for deleted files (count and percentage)
- Multiple Webhooks: Support for multiple URLs per event (pre-run, success, failure)
- Webhook Separation: Different webhook URLs for success vs failure scenarios
- Email Notifications: SMTP support with success/failure options
- Duplicate Protection: Prevents overlapping runs with lockfile mechanism
- Logging: Rotating log files with configurable size limits
- Docker Support: Easy deployment with Docker and docker-compose
- Healthchecks.io Integration: Built-in support for monitoring services
- Docker and docker-compose installed
- SnapRAID configuration file
- Access to your data drives
- Clone the repository:
git clone https://github.com/kyleinprogress/snapraidarr.git
cd snapraidarr
- Run the setup script:
chmod +x scripts/setup.sh
./scripts/setup.sh
- Configure the application:
# Edit SnapRAID configuration
nano snapraid.conf
# Edit SnapRaidarr configuration
nano config/snapraidarr.conf
- Test the installation:
./scripts/run-snapraidarr.sh
- Set up automated runs:
# Add to crontab for nightly execution
echo "0 2 * * * cd $(pwd) && ./scripts/run-snapraidarr.sh >> logs/cron.log 2>&1" | crontab -
The main configuration file is located at config/snapraidarr.conf
:
[general]
lock_directory = /app/locks
max_runtime_hours = 12
[snapraid]
executable = /usr/local/bin/snapraid
config_file = /etc/snapraid.conf
run_scrub = true
scrub_percentage = 5
scrub_age = 10
[safety]
max_deleted_files = 50
max_deleted_percentage = 5.0
[logging]
log_file = /app/logs/snapraidarr.log
log_level = INFO
max_log_size_mb = 10
backup_count = 5
[email]
enabled = false
smtp_server = smtp.gmail.com
smtp_port = 587
use_tls = true
username = [email protected]
password = your_app_password
from_email = [email protected]
to_email = [email protected]
send_on_success = true
send_on_failure = true
[webhooks]
enabled = true
timeout = 30
pre_run_urls = http://localhost:7878/api/v3/system/shutdown?apikey=KEY1,http://localhost:8989/api/v3/system/shutdown?apikey=KEY2,https://hc-ping.com/uuid/start
post_run_success_urls = http://localhost:7878/api/v3/system/restart?apikey=KEY1,http://localhost:8989/api/v3/system/restart?apikey=KEY2,https://hc-ping.com/uuid
post_run_fail_urls = http://localhost:7878/api/v3/system/restart?apikey=KEY1,http://localhost:8989/api/v3/system/restart?apikey=KEY2,https://hc-ping.com/uuid/fail
Update the docker-compose.yml
file to match your system:
version: '3.8'
services:
snapraidarr:
build: .
container_name: snapraidarr
restart: unless-stopped
volumes:
# Mount your data drives (adjust paths as needed)
- /mnt/disk1:/mnt/disk1:rw
- /mnt/disk2:/mnt/disk2:rw
- /mnt/parity1:/mnt/parity1:rw
# Configuration, logs, and locks
- ./config:/app/config:rw
- ./logs:/app/logs:rw
- ./locks:/app/locks:rw
# SnapRAID config file
- ./snapraid.conf:/etc/snapraid.conf:ro
network_mode: host
environment:
- TZ=America/New_York
profiles:
- manual
SnapRaidarr can automatically disable imports during SnapRAID operations:
# Disable all instances before SnapRAID runs
pre_run_urls = http://radarr1:7878/api/v3/system/shutdown?apikey=KEY1,http://sonarr1:8989/api/v3/system/shutdown?apikey=KEY2
# Re-enable on success
post_run_success_urls = http://radarr1:7878/api/v3/system/restart?apikey=KEY1,http://sonarr1:8989/api/v3/system/restart?apikey=KEY2
# Re-enable on failure (ensures services restart)
post_run_fail_urls = http://radarr1:7878/api/v3/system/restart?apikey=KEY1,http://sonarr1:8989/api/v3/system/restart?apikey=KEY2
Monitor your SnapRAID runs with Healthchecks.io:
- Create a check at https://healthchecks.io
- Get your check UUID
- Add URLs to your configuration:
# Start monitoring
pre_run_urls = https://hc-ping.com/YOUR_UUID/start
# Signal success
post_run_success_urls = https://hc-ping.com/YOUR_UUID
# Signal failure
post_run_fail_urls = https://hc-ping.com/YOUR_UUID/fail
Run SnapRaidarr manually for testing:
# Using the convenience script
./scripts/run-snapraidarr.sh
# Using docker-compose directly
docker-compose run --rm snapraidarr
# With custom config file
docker-compose run --rm snapraidarr -c /app/config/custom.conf
Set up automated runs using cron:
# Edit crontab
crontab -e
# Add nightly run at 2 AM
0 2 * * * cd /path/to/snapraidarr && docker-compose run --rm snapraidarr >> logs/cron.log 2>&1
Monitor SnapRaidarr operations:
# View current logs
tail -f logs/snapraidarr.log
# View Docker logs
docker-compose logs snapraidarr
# Check for running instances
docker ps | grep snapraidarr
# Check lock status
ls -la locks/
SnapRaidarr includes configurable safety checks to prevent data loss:
- max_deleted_files: Maximum number of deleted files before aborting
- max_deleted_percentage: Maximum percentage of deleted files before aborting
Built-in lockfile mechanism prevents overlapping runs:
- Creates lock files with PID and timestamp
- Automatically removes stale locks from crashed processes
- Configurable maximum runtime before considering locks stale
- Pre-run webhooks: Disable *arr applications
- Diff operation: Check for changes and validate deletion thresholds
- Sync operation: Update parity information
- Scrub operation: Verify data integrity (optional)
- Post-run webhooks: Re-enable *arr applications based on success/failure
Permission denied errors:
# Ensure proper permissions
sudo chown -R $USER:$USER ./config ./logs ./locks
chmod 755 scripts/*.sh
Webhook timeouts:
# Test webhook connectivity
curl -X GET "http://localhost:7878/api/v3/system/status?apikey=YOUR_KEY"
Lock file issues:
# Remove stale lock manually
rm -f locks/snapraidarr.lock
Container build issues:
# Force rebuild
docker-compose build --no-cache
Run with debug logging:
# Edit config/snapraidarr.conf
log_level = DEBUG
# Run manually to see detailed output
docker-compose run --rm snapraidarr
# Build the Docker image
docker-compose build
# Run tests (if available)
docker-compose run --rm snapraidarr python -m pytest
# Access container shell for debugging
docker-compose run --rm snapraidarr bash
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs and feature requests on GitHub Issues
- Documentation: Check the docs/ directory for detailed documentation
- Community: Join discussions in GitHub Discussions
- SnapRAID project for the core functionality
- *arr application developers for the API integrations
- Docker community for containerization best practices