Smtp – queue

List messages:

mailq
or
postqueue -p

View message content:

postcat -vq <msgId>

Reprocess messages:

postqueue -f
or
postfix flush

Delete messages selectively:

mailq | tail +2 | awk 'BEGIN { RS = "" } / falko@example\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -

Postgresql – migrate a database

Dump source database:

pg_dump -C -h hostname -U postgres databse > database.sql

Load the structure into the new database:

psql -U postgres -d database -f database.sql

Postgresql – create a database

Log in to the database:

psql -U postgres

Execute the following commands:

CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;

For PostgreSQL servers with versions greater than 15, we have to run the following:

\c yourdbname
GRANT USAGE, CREATE ON SCHEMA public TO youruser;