Dec 4, 2024 4 min read

Lidarr: The Ultimate Self-Hosting Setup

Lidarr: The Ultimate Self-Hosting Setup
Table of Contents

Lidarr is an open-source music collection manager that allows users to automatically download, organize, and manage their music libraries. Designed for self-hosting, it integrates seamlessly with download clients and indexers, making it an excellent choice for music enthusiasts who want complete control over their data and environment. In this guide, we’ll walk through installing Lidarr, configuring it for secure, efficient access, managing logs, setting up backups, and leveraging its advanced features.

Installing Lidarr

πŸ“¦ Docker/Docker Compose Setup

Docker is the preferred method for deploying Lidarr due to its ease of use and isolation. Below is a docker-compose.yml file configured for Lidarr:


version: '3.8'

services:

lidarr:

image: linuxserver/lidarr:latest

container_name: lidarr

environment:

- PUID=1000 # Adjust to your user ID

- PGID=1000 # Adjust to your group ID

- TZ=America/New_York # Set your timezone

volumes:

- /path/to/config:/config # Configuration data

- /path/to/music:/music # Music library

- /path/to/downloads:/downloads # Downloads directory

ports:

- 8686:8686 # Lidarr web UI

restart: unless-stopped

To deploy Lidarr using Docker Compose, follow these steps:


mkdir lidarr && cd lidarr

nano docker-compose.yml

## Start the container

docker-compose up -d

## Verify the container is running

docker ps

Access Lidarr via http://<your-server-ip>:8686.

πŸš€ Manual Installation

For those not using Docker, install Lidarr manually on a Linux server:


## Update system and install dependencies

sudo apt update && sudo apt upgrade -y

sudo apt install curl mediainfo sqlite3 -y

## Download the latest Lidarr release

curl -L -o Lidarr.tar.gz "https://github.com/Lidarr/Lidarr/releases/latest/download/linux.tar.gz"

## Extract and move to /opt

tar -xvzf Lidarr.tar.gz

sudo mv Lidarr /opt/lidarr

## Create a systemd service file

sudo nano /etc/systemd/system/lidarr.service

Add the following content to the service file:


[Unit]

Description=Lidarr Daemon

After=syslog.target network.target

[Service]

User=<your-user>

Group=<your-group>

UMask=002

ExecStart=/opt/lidarr/Lidarr -nobrowser -data=/opt/lidarr/config

Restart=on-failure

[Install]

WantedBy=multi-user.target

Enable and start the service:


sudo systemctl enable lidarr

sudo systemctl start lidarr

Access Lidarr at http://<your-server-ip>:8686.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To expose Lidarr via a domain and route traffic securely, create an Nginx server block:


sudo nano /etc/nginx/sites-available/lidarr

Add the following configuration:


server {

listen 80;

server_name lidarr.example.com;

location / {

proxy_pass http://localhost:8686;

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;

proxy_redirect off;

}

}

Enable the configuration and reload Nginx:


sudo ln -s /etc/nginx/sites-available/lidarr /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure the reverse proxy with Let's Encrypt:


## Install Certbot

sudo apt install certbot python3-certbot-nginx -y

## Obtain and apply SSL certificate

sudo certbot --nginx -d lidarr.example.com

## Test auto-renewal

sudo certbot renew --dry-run

Logging and Debugging Lidarr

πŸ—ƒοΈ Enabling Debug Logs

To enable debug logs in Lidarr, navigate to Settings > General > Logging in the web UI and set the log level to Debug.

πŸ“„ Viewing Logs

For Docker installations, view logs using:


docker logs lidarr

For manual installations, check the log file:


tail -f /opt/lidarr/config/logs/lidarr.txt

πŸ› οΈ Troubleshooting Common Issues

If Lidarr fails to start, look for errors in the logs. For example:

  • Port conflicts: Ensure no other service uses port 8686.

  • Permission issues: Ensure Lidarr has access to its directories.

πŸ“€ Exporting Logs

To send logs to an external ELK Stack:


## Install Filebeat

sudo apt install filebeat -y

## Configure Filebeat to monitor Lidarr logs

sudo nano /etc/filebeat/filebeat.yml

Add Lidarr's log path under filebeat.inputs:


- type: log

paths:

- /opt/lidarr/config/logs/*.txt

Restart Filebeat:


sudo systemctl restart filebeat

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup Lidarr’s configuration files and database:


tar -czvf lidarr-backup.tar.gz /path/to/config

πŸ”„ Database Backups

If Lidarr uses SQLite for its database, back it up specifically:


cp /path/to/config/lidarr.db /path/to/backup/lidarr.db.bak

πŸ“… Automated Backup Scripts

Create a cron job for periodic backups:


crontab -e

Add the following line:


0 2 * * * tar -czvf /path/to/backup/lidarr-$(date +\%F).tar.gz /path/to/config

Updating and Upgrading Lidarr

⬆️ Updating Docker Images

For Docker installations:


docker-compose pull lidarr

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations:


## Stop the service

sudo systemctl stop lidarr

## Download and replace the binaries

curl -L -o Lidarr.tar.gz "https://github.com/Lidarr/Lidarr/releases/latest/download/linux.tar.gz"

tar -xvzf Lidarr.tar.gz

sudo mv Lidarr /opt/lidarr

## Start the service

sudo systemctl start lidarr

πŸ” Checking for Updates

Visit Lidarr’s GitHub releases page or check the update section in the web UI.

Leveraging Lidarr’s Unique Features

πŸ”§ Enabling APIs

Activate Lidarr’s API under Settings > General > Security. To test the API:


curl -H "X-Api-Key: <your-api-key>" http://localhost:8686/api/v1/system/status

🌟 Advanced Configurations

Integrate Lidarr with third-party tools like Sonarr or Radarr by setting up download clients and indexers under Settings > Download Clients and Settings > Indexers.

Wrapping Up

This guide covered the essential aspects of deploying, configuring, and managing Lidarr. By following these steps, you can create a powerful, self-hosted music management solution tailored to your needs. With its robust features and APIs, Lidarr empowers you to automate and optimize your music collection effortlessly. Start exploring today!

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.