Hello
these are the commands we use pretty much:
tar -xf tarname.tar -C /backupdatadir --strip-components=4
pg_restore -l /backupdatadir | sed '/MATERIALIZED VIEW DATA/d' > /restore.lst
pg_restore -U postgres -L /restore.lst -d DBNAME -j 32 /backupdatadir
vacuumdb --analyze-in-stages -U postgres --jobs 32 -d DBNAME
pg_restore -l /backupdatadir | grep 'MATERIALIZED VIEW DATA' > /refresh.lst
pg_restore -U postgres -L /refresh.lst -d DBNAME -j 32 /backupdatadir
all_days is a table yes. bdays instead is a function and it include in the first file.
Both servers have 10.4 for psql commands, we take the backup with 10.4 and we restore with 10.4
We used to have postgres9.6.6 in production and pì10.4 in preprod, and the restore went always fine. After switching to 10.4 in prod we started having the problem.