How to automate IP2Location BIN database download

This tutorial will show you how to automate the IP2Location BIN database download and it works for both the IP2Location LITE and the commercial BIN database. By automating the download process, you no longer need to worry about missing out on any of the monthly BIN database updates. Below is the step-by-step tutorial on how to automate the download in the Windows environment (using scheduled task) and in the Linux / Unix / macOS environment (using crontab).

Linux / Unix / macOS Environment

  1. Download the automation package from https://www.ip2location.com/downloads/automated-ip2location-bin-download-linux.zip
  2. Decompress and edit download-ip2location-bin.sh with any text editor.
  3. Search for TOKEN="DOWNLOAD_TOKEN” and replace the “DOWNLOAD_TOKEN” with your token. You may get your download token at your account area.
  4. Search for CODE=”DB24BIN” and replace the “DB24BIN” with the download code of the database that you would like to download
  5. Search for DBPATH="YOUR_DATABASE_LOCATION” and replace “YOUR_DATABASE_LOCATION” with your database path.
  6. Test the script by running ./download-ip2location-bin.sh. The database in the given path should be replaced with the latest version from IP2Location.
  7. Once you are satisfied with your testing, you can setup a cronjob for the monthly updates. Edit /etc/crontab using any text editor.
  8. Add the following line to the end of your content. The following line means it will execute the download and update process at 0815 on the 1st of every calendar month. To prevent bandwidth congestion and delay of the downloading, we will suggest you to set the downloading to an odd time, such as 0804, 0925, and so on.
    15 8 1 * * bash /path/to/download-ip2location-bin.sh

    Windows Environment

    1. Download the automation package from https://www.ip2location.com/downloads/automated-ip2location-bin-download-windows.zip
    2. Decompress and edit download-ip2location-bin.bat.
    3. Search for SET TOKEN=DOWNLOAD_TOKEN and replace the DOWNLOAD_TOKEN with your token. You may get your download token at your account area.
    4. Search for SET CODE=DB24BIN and replace the “DB24BIN” with the download code of the database that you would like to download.
    5. Search for SET FINALFOLDER=%ROOT%ip2location and replace %ROOT%ip2location with your database path.
    6. Test the script by double-clicking on download-ip2location-bin.bat. The database in the given path should be replaced with the latest version from IP2Location.
    7. Setup a scheduled task to run the script monthly.
    8. Once you are satisfied with your testing, you can set up the task for monthly updates. Open start menu, search and open “Task Scheduler”.
    9. In the Actions Pane, click Create Task.
    10. On the General tab of the Create Task dialog box, enter a name for the task.
    11. On the Triggers tab of the Create Task dialog box, click the New…button to create a trigger for the task.
    12. Select monthly and select the day the script will run. To prevent bandwidth congestion and delay of the downloading, we will suggest you to set the downloading to an odd time, such as 0804, 0925, and so on.
    13. Go to Actions tab, browse to download-ip2location-bin.bat and press OK to create the task.

THE POWER OF IP GEOLOCATION

Find a solution that fits.


Was this article helpful?

Related Articles