I am trying to push the pg_dump to 2 psql and to a log file but I don't want to add noise to my terminal.
Following the numerous post of the tee
tool, I reached this command which is indeed working except that the console is still flooded.
pg_dump -a -t table-country -p 5432 -U usr db-maint2 2>&1 | tee >(psql -p 5432 -U postgres db-project) >(psql -p 5432 -U postgres db-gp-projet) >"initDB_$(date +%Y%m%d_%H%M).log"
I have read around but I don't find a better solution.
Moreover, the stdout from pg_dump is displayed in the console after my command but the logs from both psql are sent to the terminal only and not the log file.
EDIT : ok I found how to output the psql to the logfile :
pg_dump -a -t table-country -p 5432 -U usr db-maint2 2>&1 | tee >(psql -p 5432 -U postgres db-project >"initDB_$(date +%Y%m%d_%H%M).log") >(psql -p 5432 -U postgres db-gp-projet >"initDB_$(date +%Y%m%d_%H%M).log") >"initDB_$(date +%Y%m%d_%H%M).log"
Actually, that logs only one of the psql command, even adding -a
handle with tee create only one psql output in the file.log.
Edit nth : No more ideas.
Edit n^th + 1 : ofc, my brain finally woke up.