Restoring DB backup of PostgreSQL >9.5

When you messed up your database of testing or production servers you usually want to restore a clean state as fast as possible with the backup and not mixing up date from the current state and the backup. An easy way to achieve this is to drop the database and create it again afterwards restore the dump.

But for PostgreSQL >9.5 there is the problem that you cannot drop a database if others are connected to the database which is very likely when you have services running.

Continue reading →

Copy Command to Editor

Have you ever struggled with a command which does not work out of the box and after some tries you copied it to an editor to work on it or use it as a base for a shell script. There is a easy way to achieve that by using a keyboard shortcut. Just keep the line in prompt you want to put to an editor and the hit + and then . You will then automatically open the editor set at $EDITOR and the prompt line will be automatically copied in there.

find . type -f name java -exec stat {} \; # now press ctrl + x + e