Dec 4, 2024 3 min read

Sonarr: A Complete Checklist for Self-Hosting Success

Sonarr: A Complete Checklist for Self-Hosting Success
Table of Contents

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:

  1. 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.

  1. 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:

  1. Install dependencies:

sudo apt update

sudo apt install -y curl mediainfo sqlite3

  1. 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

  1. 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:

  1. 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;

}

}

  1. Test and reload Nginx:

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your Sonarr instance with Let's Encrypt SSL:

  1. Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

  1. Obtain and configure an SSL certificate:

sudo certbot --nginx -d sonarr.yourdomain.com

  1. 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:

  1. Go to Settings > General > Logging.

  2. 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:

  1. Use Filebeat to ship logs:

sudo apt install filebeat

  1. 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:

  1. Toggle Enable API to On.

  2. 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:

  1. Go to Settings > Connect > Add.

  2. 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.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.