In my work I'm often in situation where I want to restart remote server, and then immediately connect to it over ssh.
This can be done by repeating ssh HOST in shell, but it gets tedious.
In my work I'm often in situation where I want to restart remote server, and then immediately connect to it over ssh.
This can be done by repeating ssh HOST in shell, but it gets tedious.
Recently, on irc, there have been some talks with people using various pg_dump/pg_dumpall calls to get dumps of database.
I voiced my ideas, but figured it could be good subject for a blog post.
Continue reading How to effectively dump PostgreSQL databases
Recently I've seen case like:
Why? How to avoid the problem?
Continue reading How to run short ALTER TABLE without long locking concurrent queries
I assume most of you are familiar with watch program. If not – it shows, periodically, output of a command.
I was missing similar functionality for tmux, especially when I have multiple windows/panes.
So I wrote tmux_watch_many.
How to use it?
Continue reading New shell_util to watch output in multiple tmux panes at once
I am doing quite a lot of work inside tmux. I especially love that I can start multiple windows/panes and use them to run the same thing across multiple servers, while still having normal shell access between steps.
This thing was greatly improved when I wrote tmux_send_to_many, but one thing was missing – waiting for the thing, running in tmux window to end.
Generally, I had to look at all the windows, and decide when to launch next step on my own.
Not anymore.
I wrote previously about tmux_send_to_many and group_by shell tools that I authored.
Since then I got some more ideas for changes, and for new tool, so figured I'll make an honest git repo for it. Repo is on GitLab, and all the tools inside can be freely used.
While I was doing it, I fixed some things in tmux_send_to_many.
And then – I remembered that for long time I was missing “visual-sleep" type of tool. One that will show some progress information while it's working.
Enter vsleep.
Continue reading visual sleep in shell, and shell_utils repo information
I assume that everyone reading my blog understands GROUP BY clause in SQL.
Lately I've been doing some maintenance work, and found myself in a position that I could really use similar thing in shell.
Tmux is terminal multiplexer. Kinda like old screen, but with much more functionality.
When I work on my servers, it's pretty common that I have to do the same things to multiple servers. To make my life easier I start tmux, and in there start many “windows", each related to work on single server.
I name the windows in a way that let's me quickly find them, without false positives.
For example, if I'd have to upgrade servers db1..db5 then I'd create windows “up-db1" .. “up-db5", and each window would work on single server.
This is already scriptable – let's assume I'd want to show uptime in all of the windows, I can:
tmux lsw -F '#W' | grep -E '^up-db[0-9]+$' | xargs -r -d$'\n' -I% tmux send-keys -t % uptime Enter
But this gets tedious fast.
Continue reading Automation for doing stuff in multiple windows in tmux
I usually write about PostgreSQL, but lately someone asked for help, and one of the problems was similar to sudo command from title.
This was not the first time I saw it, so figured, I'll write a blogpost about it, just so I can refer people to it in the future.
Word of warning: this blogpost is about thing related to Bash (well, maybe other shells too, didn't really test), but since I found it while doing Pg work, and it might bite someone else doing Pg related work, I decided to add it to “postgresql" tag.
So, due to some work I had to do, I needed a quick, repeatable way to setup some Pg instances, replication between them, and some data loader. All very simple, no real problems. At least that's what I thought…