Consider this pg_restore command:
pg_restore -h 123.123.123.123 -d my_database -U my_user --no-owner --no-privileges --no-password -t specific_table 616f6d35-202104.backup
When I run it locally it works. But when I run it my ECS instance it does not restore. There is no error and exit code is 0.
If I create the db in the statement (by adding the --create flag and changing my_database to postgres) like so:
pg_restore -h 123.123.123.123 -d postgres -U my_user --create --no-owner --no-privileges --no-password -t specific_table 616f6d35-202104.backup
It still works locally. When I run it in ECS it creates the db but still does not restore the table. And if I exclude the specific table:
pg_restore -h 123.123.123.123 -d my_database -U my_user --no-owner --no-privileges --no-password 616f6d35-202104.backup
Then it works. But it loads the whole database which I don't want. So it's something to do with the -t flag that works locally but not in my ECS instance.
EDIT: There does seem to be a version mis-match. The closest I could get the environments was PostgreSQL v10.16 on the ECS and v10.4 on the target EC2 that has the Postgres server 123.123.123.123. Still does not work. Could this be the issue? If so how do I install a specific minor version of postgresql or postgresql-client?
For the ECS in the docker file I have:
RUN apt-get update
RUN apt-get install -y curl ca-certificates gnupg
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" | tee /etc/apt/sources.list.d/docker.list
RUN apt-get update
RUN apt-get install -y postgresql-10
This gets me to v10.16 on the ECS (which still doesn't work). But if I change that last line to specify a specific minor version (to more closely match the EC2's version) it can't find it.
RUN apt-get install -y postgresql-10.5
E: Unable to locate package postgresql-10.5
E: Couldn't find any package by glob 'postgresql-10.5'
E: Couldn't find any package by regex 'postgresql-10.5'
Again, locally it works - and the version I have locally is v10.5.
EDIT-2: I have a little more visibility on this. Looks like it outputs these two lines and then stops - still no error:
pg_restore: connecting to database for restore
pg_restore: implied data-only restore
It seems 'implied data-only restore' might not be causing an issue though - there seems to be output that should come after it. But output just stops in my case.