0

A Prestashop e-commerce website is using MaxMind's GeoLite2-City database for country blocking. Instead of geoipupdate it uses this cron command to keep that database up to date:

/usr/bin/curl -L --silent 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz' | /bin/zcat > '/home/u3p3/domains/xyz.tld/public_html/app/Resources/geoip/GeoLite2-City.mmdb'

As of January 2020 the geolite databases are no longer publicly available, and requires an account and license key. Within less then 21 days of not updating the geolite mmdb file, Prestashop is stopped with a 500 error:

InvalidDatabaseException: Error opening database file.

How to make the cron job run again with the new license file from the new download location?

1

Prestashop 1.7.x

This is the cron job that only extracts the GeoLite2-City.mmdb file from the zipped tar file to the location that the Prestashop built-in geoip module requires:

/usr/bin/curl -L --silent 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz' | /bin/tar -C '/home/u3p3/domains/xyz.tld/public_html/app/Resources/geoip' -xvz --keep-newer-files --strip-components=1 --wildcards '*GeoLite2-City.mmdb'

--keep-newer-files

The "keep newer files" flag is here to reduce write i/o. Existing identical versions of the file are not overwritten. When there is no update in the upstream version, the tar output will become something like:

/bin/tar: Current `GeoLite2-City.mmdb' is newer or same age

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.