homelabprivacy

Archive YouTube channels with yt-dlp on bare metal

🤖 Researched and drafted automatically from the official docs, and reviewed before publishing. Commands are taken from the source projects — but always sanity-check before running anything on your own hardware.

yt-dlp is a command-line downloader that pulls video and audio from YouTube and thousands of other sites. Unlike cloud-based tools, running it on bare metal gives you full control over what you download, how you store it, and when you run jobs. This guide walks you through installing yt-dlp, configuring it for channel subscriptions, and automating downloads with a cron job.

Install yt-dlp

  1. SSH into your homelab server and download the latest binary for your platform. For Linux x86_64:
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/yt-dlp
chmod +x ~/yt-dlp
  1. Verify the download by checking the SHA256 sum:
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/SHA2-256SUMS -o SHA2-256SUMS
sha256sum -c SHA2-256SUMS | grep yt-dlp
  1. Move the binary to a system path:
sudo mv ~/yt-dlp /usr/local/bin/
  1. Test the installation:
yt-dlp --version

Create a download directory and config

  1. Make a directory to store your archive:
mkdir -p ~/videos/youtube-archive
cd ~/videos/youtube-archive
  1. Create a configuration file at ~/.config/yt-dlp/config:
mkdir -p ~/.config/yt-dlp
  1. Edit the config file with your preferences:
cat > ~/.config/yt-dlp/config << 'EOF'
# Output template: organize by channel and date
-o "%(uploader)s/%(upload_date)s - %(title)s.%(ext)s"

# Download best available quality
-f "bestvideo+bestaudio/best"

# Merge video and audio
--merge-output-format mp4

# Keep original upload date
--dateafter now-30d

# Ignore errors and continue
--ignore-errors

# No playlist items (download full channels)
--no-playlist
EOF

Adjust --dateafter now-30d to control how far back you want to download. Use now-1y for one year, now-6m for six months, etc.

Download a single channel

  1. Test a download with a specific channel URL:
yt-dlp "https://www.youtube.com/c/CHANNEL_NAME/videos"

Replace CHANNEL_NAME with the actual channel. yt-dlp will create subdirectories by uploader and organize videos by date.

  1. Check the output:
ls -la ~/videos/youtube-archive/

Automate downloads with cron

  1. Create a script to download multiple channels:
cat > ~/download-channels.sh << 'EOF'
#!/bin/bash
set -e

LOG_FILE="$HOME/videos/youtube-archive/download.log"
echo "[$(date)] Starting YouTube downloads" >> "$LOG_FILE"

# Add your channel URLs here, one per line
CHANNELS=(
  "https://www.youtube.com/c/CHANNEL_1/videos"
  "https://www.youtube.com/c/CHANNEL_2/videos"
  "https://www.youtube.com/@CHANNEL_3/videos"
)

for channel in "${CHANNELS[@]}"; do
  echo "[$(date)] Downloading $channel" >> "$LOG_FILE"
  yt-dlp "$channel" >> "$LOG_FILE" 2>&1 || echo "[$(date)] Error downloading $channel" >> "$LOG_FILE"
done

echo "[$(date)] Download complete" >> "$LOG_FILE"
EOF
chmod +x ~/download-channels.sh
  1. Edit your crontab to run the script daily:
crontab -e
  1. Add a line to run the download script at 2 AM daily:
0 2 * * * /home/YOUR_USER/download-channels.sh

Replace YOUR_USER with your actual username.

  1. Verify the cron job is scheduled:
crontab -l

Monitor disk usage

  1. Check how much space your archive is using:
du -sh ~/videos/youtube-archive/
  1. List the largest channels:
du -sh ~/videos/youtube-archive/*/ | sort -hr | head -10
  1. If you need to limit downloads, modify the config to skip videos larger than a threshold or only download the last N videos per channel. Consult the yt-dlp documentation for options like --max-filesize and --playlist-items.

Security and network notes

Keep this service on your LAN and behind a VPN if accessed remotely. Do not expose yt-dlp or your download directory to the public internet. YouTube’s terms of service allow personal archival, but respect the platform’s policies and the creators whose content you download. If a creator requests removal, delete the files.

Is it worth it?

Yes, if you want a reliable offline copy of educational content, tutorials, or channels that might disappear. yt-dlp is rock-solid, handles format changes fast, and costs nothing but disk space. The setup takes an hour. The main drawback is storage—4K video adds up quickly, so be selective about quality and date ranges. For a homelab, this is a clean, self-hosted alternative to cloud recording services.

Related video

New self-hosted AI & homelab shorts, daily.

Subscribe on YouTube

Related guides

← All guides