Sonarr is a powerful, self-hosted PVR (Personal Video Recorder) for automatically downloading TV shows from your favorite sources. Designed with automation and flexibility in mind, Sonarr integrates seamlessly with download clients while offering robust scheduling, monitoring, and organization of your media library. This guide will walk you through installing, securing, configuring, and managing Sonarr, ensuring an optimal self-hosting experience.
Installing Sonarr
π¦ Docker/Docker Compose Setup
Docker provides an isolated, consistent environment for running Sonarr with minimal configuration. Here's how to deploy Sonarr using Docker Compose:
- Create a
docker-compose.yml
file:
version: "3.9"
services:
sonarr:
image: linuxserver/sonarr:latest
container_name: sonarr
environment:
- PUID=1000 # Adjust for your user ID
- PGID=1000 # Adjust for your group ID
- TZ=Etc/UTC # Set your timezone
volumes:
- /path/to/config:/config # Configuration files
- /path/to/tv:/tv # TV library
- /path/to/downloads:/downloads # Downloads folder
ports:
- 8989:8989 # Web interface
restart: unless-stopped
Replace /path/to/
with the preferred paths on your server.
- Deploy with Docker Compose:
docker-compose up -d
This command will pull the Sonarr image, create the container, and start it in detached mode.
π Manual Installation
For those managing servers without Docker, you can install Sonarr directly on Linux:
- Install dependencies:
sudo apt update
sudo apt install -y curl mediainfo sqlite3
- Add the official Sonarr repository and install Sonarr:
curl -fsSL https://raw.githubusercontent.com/Sonarr/Sonarr/develop/packaging/debian/sonarr.list | sudo tee /etc/apt/sources.list.d/sonarr.list
sudo apt update
sudo apt install -y sonarr
- Start and enable Sonarr:
sudo systemctl start sonarr
sudo systemctl enable sonarr
Access the web interface at http://<your-server-ip>:8989
.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
To access Sonarr via a custom domain or subdomain, configure Nginx as a reverse proxy:
- Create an Nginx server block:
server {
listen 80;
server_name sonarr.yourdomain.com;
location / {
proxy_pass http://localhost:8989;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Sonarr instance with Let's Encrypt SSL:
- Install Certbot:
sudo apt install -y certbot python3-certbot-nginx
- Obtain and configure an SSL certificate:
sudo certbot --nginx -d sonarr.yourdomain.com
- Automate certificate renewal:
sudo systemctl enable certbot.timer
Logging and Debugging Sonarr
ποΈ Enabling Debug Logs
Debug logs provide detailed insights that help troubleshoot issues. Enable them via the Sonarr web interface:
-
Go to Settings > General > Logging.
-
Change the log level to
Debug
and save.
π Viewing Logs
Access logs depending on your setup:
- Docker:
docker logs sonarr
- Manual installation:
tail -f /var/lib/sonarr/logs/sonarr.txt
π οΈ Troubleshooting Common Issues
For example, if Sonarr cannot connect to a download client:
-
Check logs for connection errors.
-
Ensure the clientβs IP, port, username, and password match Sonarrβs settings.
π€ Exporting Logs
Push logs to an external system like the ELK Stack:
- Use
Filebeat
to ship logs:
sudo apt install filebeat
- Configure
filebeat.yml
to monitor Sonarrβs log path and output to Elasticsearch.
Backup and Restore
ποΈ File-Based Backups
Backup Sonarrβs configuration and database:
tar -czvf sonarr-backup.tar.gz /path/to/config
π Database Backups
Sonarr stores data in a SQLite database. Backup it specifically:
cp /path/to/config/sonarr.db /path/to/backup/sonarr.db
π Automated Backup Scripts
Schedule periodic backups using cron
:
crontab -e
Add the following line:
0 2 * * * tar -czvf /backup/sonarr-$(date +\%F).tar.gz /path/to/config
Updating and Upgrading Sonarr
β¬οΈ Updating Docker Images
Keep your Docker image updated with:
docker-compose pull
docker-compose up -d
π οΈ Manual Updates
For manually installed Sonarr:
sudo apt update
sudo apt upgrade sonarr
π Checking for Updates
Sonarr automatically checks for updates in the web interface under System > Updates.
Leveraging Sonarrβs Unique Features
π§ Enabling APIs
Sonarr offers an API for external integrations. Enable it under Settings > General > Security:
-
Toggle Enable API to
On
. -
Use the API key for requests:
curl -H "X-Api-Key: <your-api-key>" http://localhost:8989/api/v3/system/status
π Advanced Configurations
Integrate Sonarr with tools like Radarr for movies:
-
Go to Settings > Connect > Add.
-
Select Custom Script, configure triggers, and automate workflows.
Wrapping Up
This guide covered the end-to-end process of deploying, configuring, and managing Sonarr. By following these steps, youβve set up a flexible, robust TV automation tool tailored to your needs. Dive into its advanced features to unlock its full potential and enjoy complete control over your media library.