Laravel Backup pg_dump server version Mismatch

I have an error log like this when doing a backup

My Fly Apps structure.


The top being the laravel app. the db below. (1 is unused).

My Dockerfile, contains this line at 16

RUN apt-get update && apt-get install -y \
    jpegoptim optipng pngquant gifsicle libpng-dev \
    imagemagick php${PHP_VERSION}-imagick php${PHP_VERSION}-gd php-intl ghostscript \
    postgresql \
    tesseract-ocr \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

I tried to change the postgresql to postgresql-14, but no luck.


tried to search the package, but it is stuck at 12.

Anyone can help? @fideloper-fly @fideloper Thanks!

Hi!

Run the following in your Dockerfile to get the posgresql 14 client (just the client, not the server):

apt-get update
apt-get install -y lsb-release wget
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get install -y postgresql-client-14

You can add the Dockerfile-friendly version of those commands to an existing RUN command:

RUN ...other stuff here... \
    && apt-get install -y lsb-release wget \
    && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt-get install -y postgresql-client-14

Let me know how it goes!

I seperate the RUN to be like this. didn’t get there yet

RUN apt-get update && apt-get install -y lsb-release wget \
    && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt-get install -y postgresql-client-14

That line cause this error:

Error: failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c apt-get update && apt-get install -y lsb-release wget     && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list     && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -     && apt-get install -y postgresql-client-14]: exit code: 100

Looks like I missed an additional apt-get update that’s needed after adding the pgsql repository that provides the newer versions of the software - try this:

RUN apt-get update && apt-get install -y lsb-release wget \
    && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
+   && apt-get update \
    && apt-get install -y postgresql-client-14

Woah, it works! Thanks @fideloper-fly Backup completed :sweat_smile::pray:t2:

Should this be included in a blogpost for artisans who wants to backup their fly app?

I updated the docs with that! Laravel and Databases · Fly Docs

(I may also include it in the base image, gonna see if it makes sense to)

1 Like

I think it will make sense if the user uses fly’s pg, otherwise it won’t be that useful.

Maybe the middleground is we can add an if. much like the conditional check with octane check

So maybe like this?

RUN if grep -Fq "pgsql" /var/www/html/fly.toml; then \
 apt-get update && apt-get install -y lsb-release wget \
    && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt-get update \
    && apt-get install -y postgresql-client-14 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*; \
   else \
         # handle mysql case, and so on...

What do you think?

1 Like