Catty ssh is cool
Last update on .
Was looking up something for a backup operation and saw a command where someone was catting from ssh... I'd never thought of doing it before, but it does make sense:
ssh dbhost.example.com "pg_dumpall | gzip -c" > ~/cluster.sql.gzshould connect and dump the entire DB cluster (gzipped) to your local machine.
ssh dbhost.example.com "gunzip -c | pg_restore" < ~/cluster.sql.gzshould rebuild the database on the machine (assuming you've rebuilt the cluster in the meantime). One could, for that matter, pipe the result of the downloaded db directly into pg_restore on another machine (potentially also going over an ssh link). Of course, if your ssh link goes away, sucks to be you, but still a cool effect.
Comments are closed.
Pingbacks are closed.
Ryan Beesley on 10/14/2010 6:37 p.m. #
I wrote something similar a number of years ago to push SSH keys to a remote server and let me log in as an authorized user without the need for typing in my password again. The shell script I wrote would actually look on the remote system and generate the appropriate directories if they didn't exist, and add the keys to the file without otherwise altering the contents of the file. Then the next time you ssh'd into the system, you would already be authorized and wouldn't need to use your password. It was a cool little hack, that only required you to log in the one time, everything else was piped back and forth.