I can not run Pi-Hole v6 yet on the new host due to current dependencies with another software and the v6 API changes. Updating that component will take a few weeks to probably months. Until that point, I am stuck with v5 version.
Question:
How to setup an older Pi-Hole version on a new host?
I want to maintain the same latest v5 Pi-Hole version for the migration (install the same v5 version on the new host), then resolve the API dependencies later on and update Pi-Hole to v6 on the new host.
So I‘m starting to think about this on my own:
Everything in Linux is a file. How about making an advantage out of that by
just installing old lighttpd again and then
copying all pi-hole relevant files (application, configs, database, systemd service definitions, cron jobs, …) to the new host
So basically by not installing a former pi-hole release but by cloning an existing installation to a new host. Would likely also make using the teleporter unnecessary.
Unless someone can help on the original question…
…I think I could investigate more on that approach.
Maybe digging into GitHub would help too, maybe there‘s a basic install script of the former v5 release or sth. like that - but I‘m not really into that.
So set up a fresh Pi-hole v5 instance to test/compared: I downloaded v5.18.4 tag installer, added a git reset --hard <latest_v5_tag> to the end of the make_repo function (tag based on whether it's core or web), to be on master branch but latest v5 state, and changed the FTL URL to https://github.com/pi-hole/FTL/releases/download/v5.25.2 (latest v5 tag).
plus importing a teleporter backup and a former v5 installation would be migrated?
Yes that's how far I came in the last hour, without actually running the installer yet:
cd /etc
sudo git clone --branch v5.18.4 https://github.com/pi-hole/pi-hole.git /etc/.pihole
cd /etc/.pihole
sudo nano "automated install/basic-install.sh" (gem. https://github.com/pi-hole/pi-hole/pull/5968#issuecomment-2676409143)
--> 1. Nach Funktion "make_repo" suchen und am Ende der Funktion "git reset --hard 5.18.4" einfügen
--> 2. Nach "url="https://github.com/pi-hole/ftl/releases/latest/download"" suchen und ersetzen durch "url="https://github.com/pi-hole/ftl/releases/download/v5.25.2""
sudo "./automated install/basic-install.sh"
Afterwards copy single files (to be checked) from `/etc/pihole` and `/etc/dnsmasq.d` and check pihole status.
Hopefully @MichaIng can confirm I understood and replicated his instructions correctly. I'll power up my test machine for this to be run tomorrow (Sunday) morning.
In make_repo you need to do it conditionally, v5.21 for the web repo, v5.18.4 for the core repo.
Like so:
if [[ $directory == '/etc/.pihole' ]]; then
git reset --hard v5.18.4
else
git reset --hard v5.21
fi
This needs to be located somewhere between the other git reset --hard call in this function and return.
Otherwise looks good.
Oh wait, you cloned the repo manually to /etc/.pihole already. In this case, make_repo is not called, but update_repo instead, for the core. To assure there are no other side effects or cloning the repo pior to running the installer, I would either clone it elsewhere, or download the installer manually elsewhere:
cd ~
wget 'https://raw.githubusercontent.com/pi-hole/pi-hole/v5.18.4/automated%20install/basic-install.sh'
chmod +x basic-install.sh
nano basic-install.sh
...
2.a) Add this at the end of the make_repo function (replace the existing last 3 lines):
# Make sure a specific release is pulled/installed
if [[ $directory == '/etc/.pihole' ]]; then
git reset --hard v5.18.4
else
git reset --hard v5.21
fi
# Move back into the original directory
popd &> /dev/null || return 1
return 0
2.b) Search for url="https://github.com/pi-hole/ftl/releases/latest/download" and replace it with url="https://github.com/pi-hole/ftl/releases/download/v5.25.2".
Then run the installation with sudo ./basic-install.sh
Startup Pi-Hole, check basic functionality.
Import teleporter backup.
Restore likely still needed additional data from /etc/pihole (like at least pihole-FTL.db for statistics) and /etc/dnsmasq.d (always with shutdown pi-hole, both instances on the old and the new host).
Confirmed @MichaIng? Or did I still mix up something?
During a first try on my test machine I got this which makes me a bit nervous (it pulled a v6 version?)
[i] Using privacy level: 0
[✗] Check for existing repository in /etc/.pihole
[i] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole...HEAD ist jetzt bei 9fe687b Pi-hole Core v6.0.5 (#6042)
[✓] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole
fatal: Kein Git-Repository (oder irgendeines der Elternverzeichnisse): .git
[✗] Check for existing repository in /var/www/html/admin
[i] Clone https://github.com/pi-hole/web.git into /var/www/html/admin...HEAD ist jetzt bei 2544117 Pi-hole Web v6.0.2 (#3272)
[✓] Clone https://github.com/pi-hole/web.git into /var/www/html/admin
fatal: Kein Git-Repository (oder irgendeines der Elternverzeichnisse): .git
[i] Checking for / installing Required dependencies for Pi-hole software...
[✓] Checking for cron
[✓] Checking for curl
[✓] Checking for iputils-ping
Looks good. It pulls v6 at first, but the new git reset --hard sets it back to v5.
But I missed the popd command before return, which moves you outside of the git dir. Hence add the new block before that popd &> /dev/null || return 1 line.
EDIT: Probably best before the chmod. It does not seem to change any permissions as of defaults, but for minimal difference to original code/result.
OK, thanks! I'll update that and give it a 2nd try. For the first attempt on the test machine setting up Pi-Hole failed with
[✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
Error: Unable to initialize configuration file /etc/pihole/pihole-FTL.conf
[✗] Failure in dependent config copy function.
probably as the test machine is not running the latest Raspberry Pi OS version (I had to pass the PIHOLE_SKIP_OS_CHECK=true variable to start the setup at all). Not sure what's missing here.
I tried to run sudo pihole -r (run a repair) which is kind of "dangerous" as it directly targets the latest release. That's another story but somehow - if I could manage to migrate the v5 installation to the new host at all - I'd like to make sure this also only points at the latest v5 release for the remaining time until I can finally upgrade to v6.
I'll likely now try the v5 setup directly on the productive new host (running latest and supported OS release).
Makes sense that old installer with old FTL but new core and web won't work. Adding the new code block before popd is essential.
pihole -r and pihole -up cannot be used with this v5 instance, as both will update the repositories to v6. You'd need to adjust scripts in /opt/pihole if those shall work.
Interestingly on a supported host (Pi OS 12) the modified basic-install.sh script ran into issues with this:
[✗] Retrieval of supported OS list failed. dig failed with return code 9.
Unable to determine if the detected OS (Debian 12) is supported
Possible causes for this include:
- Firewall blocking certain DNS lookups from Pi-hole device
- ns1.pi-hole.net being blocked (required to obtain TXT record from versions.pi-hole.net containing supported operating systems)
- Other internet connectivity issues
https://docs.pi-hole.net/main/prerequisites/#supported-operating-systems
If you wish to attempt to continue anyway, you can try one of the following commands to skip this check:
e.g: If you are seeing this message on a fresh install, you can run:
curl -sSL https://install.pi-hole.net | sudo PIHOLE_SKIP_OS_CHECK=true bash
If you are seeing this message after having run pihole -up:
sudo PIHOLE_SKIP_OS_CHECK=true pihole -r
(In this case, your previous run of pihole -up will have already updated the local repository)
It is possible that the installation will still fail at this stage due to an unsupported configuration.
If that is the case, you can feel free to ask the community on Discourse with the Community Help category:
https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/
No idea why, as nslookup ns1.pi-hole.net from the host itself gives
Using the PIHOLE_SKIP_OS_CHECK=true made the installation of the latest v5 work:
I'm trying to migrate the settings (import teleporter backup, copy over pihole-FTL.db etc.) now and see if I really get a 1:1 copy/duplicate of Pi-Hole on the other (new) host.
@MichaIng any clue which script in /opt/pihole is used for running pihole -r and therefore would need to be tweaked using the latest v5 (like with basic-install.sh probably)?