Skip to content

AdGuard Home

AdGuard Home (AGH) is used to filter ads and as my DNS rewites (assign hostnames to IP addresses).

I have two instances of AGH running: one as an LXC and one on a bare metal Raspberry Pi 2.

Syncing between the instances are done using AdGuard Home Sync

🛠 Installation

Default Port: 3000

Configuration path: /opt/AdGuardHome

bash -c "$(curl -sL https://github.com/community-scripts/ProxmoxVE/raw/main/ct/adguard.sh)"
bash -c "$(curl -sL https://github.com/asylumexp/Proxmox/raw/main/ct/adguard.sh)"

⚙ Config

/opt/AdGuardHome/AdGuardHome.yaml

rewrites:
    - domain: adguard02.l.nicholaswilde.io
      answer: 192.168.3.250

🤝 Service

/etc/systemd/system/AdGuardHome.service

cat > /etc/systemd/system/AdGuardHome.service <<EOF
[Unit]
Description=AdGuard Home: Network-level blocker
ConditionFileIsExecutable=/opt/AdGuardHome/AdGuardHome

After=syslog.target network-online.target 

[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/AdGuardHome/AdGuardHome "-s" "run" "-c" "/root/git/nicholaswilde/homelab/pve/adguardhome/AdGuardHome.yaml"

WorkingDirectory=/opt/AdGuardHome



StandardOutput=journal
StandardError=journal

Restart=always

RestartSec=10
EnvironmentFile=-/etc/sysconfig/AdGuardHome

[Install]
WantedBy=multi-user.target

EOF
curl -Lo /etc/systemd/system/AdGuardHome.service https://github.com/nicholaswilde/homelab/raw/refs/heads/main/pve/adguardhome/AdGuardHome.service
[Unit]
Description=AdGuard Home: Network-level blocker
ConditionFileIsExecutable=/opt/AdGuardHome/AdGuardHome

After=syslog.target network-online.target 

[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/AdGuardHome/AdGuardHome "-s" "run" "-c" "/root/git/nicholaswilde/homelab/pve/adguardhome/AdGuardHome.yaml"

WorkingDirectory=/opt/AdGuardHome



StandardOutput=journal
StandardError=journal

Restart=always

RestartSec=10
EnvironmentFile=-/etc/sysconfig/AdGuardHome

[Install]
WantedBy=multi-user.target

Enable service

(
 systemctl enable AdGuardHome.service && \
 systemctl start AdGuardHome.service && \
 systemctl status AdGuardHome.service
) 

🚀 Upgrade

Upgrading the app is done via the web GUI.

💾 Backup

Backups of the AdGuardHome.yaml file are managed by the backup-adguardhome.sh script. This script will automatically commit and push the encrypted AdGuardHome.yaml.enc file to the git repository when changes are detected.

✍ Manual Backup

To perform a manual backup, run the following task:

task backup

🤖 Automatic Backup (Timer)

The backup script can be run periodically using a systemd timer.

⚙ Configuration

Before installing the timer, you may need to configure the path to the backup script in pve/adguardhome/backup.service.tmpl.

By default, the ExecStart path is set to:

pve/adguardhome/backup.service.tmpl

ExecStart=/home/nicholas/git/nicholaswilde/homelab/pve/adguardhome/backup-adguardhome.sh
adguardhome/backup.service.tmpl
# This is a template for the AdGuard Home backup service.
# To use it, copy it to /etc/systemd/system/adguardhome-backup.service
# and adjust the ExecStart path if necessary.

[Unit]
Description=Back up AdGuard Home configuration

[Service]
Type=oneshot
ExecStart=/home/nicholas/git/nicholaswilde/homelab/pve/adguardhome/backup-adguardhome.sh
adguardhome/backup.timer.tmpl
# This is a template for the AdGuard Home backup timer.
# To use it, copy it to /etc/systemd/system/adguardhome-backup.timer
# and adjust the schedule in OnCalendar if necessary.

[Unit]
Description=Run AdGuard Home backup script periodically

[Timer]
# Run daily at midnight.
# You can change this to something else, e.g., "hourly", "weekly",
# or a more specific time like "*-*-* 02:00:00".
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

If your project is located elsewhere, you will need to update this path to the correct location of the backup-adguardhome.sh script.

🛠 Installation

To install and enable the timer, run the following task. This will copy the service and timer files to /etc/systemd/system/ and enable the timer.

task bt:install
(
  sudo cp ./backup.service.tmpl /etc/systemd/system/adguardhome-backup.service
  sudo cp ./backup.timer.tmpl /etc/systemd/system/adguardhome-backup.timer
  sudo systemctl daemon-reload
  sudo systemctl enable --now adguardhome-backup.timer
)

📝 Usage

You can manage the timer using the following tasks:

  • task bt:status: Check the status of the backup timer.
  • task bt:start: Start the backup timer.
  • task bt:stop: Stop the backup timer.
  • task bt:enable: Enable the backup timer to start on boot.
  • task bt:disable: Disable the backup timer from starting on boot.

🗑 Uninstallation

To uninstall the timer, run the following task:

task bt:uninstall
(
  sudo systemctl disable --now adguardhome-backup.timer
  sudo rm /etc/systemd/system/adguardhome-backup.service
  sudo rm /etc/systemd/system/adguardhome-backup.timer
  sudo systemctl daemon-reload
)

Task List

task: Available tasks for this project:
* decrypt:       Decrypt .env using SOPS
* enable:        Enable the application's systemd service.
* encrypt:       Encrypt .env using SOPS
* export:        Export the task list to `task-list.txt`.
* init:          Init
* mklinks:       Make client symlinks
* restart:       Resart service
* start:         Start service
* status:        Check the status of the application's systemd service.
* stop:          Stop service
* upgrade:       upgrade

🔗 References