0

I am trying to do a pg_dump from one server and simultaneously restore at the other server.

The command on source server (192.168.3.94):

pg_dumpall -v  | nc 192.168.3.95  4000

The command on the target server (192.168.3.95):

nc -l 4000 | psql mydb

Now I am running this from my PC via Putty. Since this process take ~5 hours, I want to background the jobs and close the terminal windows. But I am not able to figure out how to background both commands and also exit the shell.

Help!

sayeed
  • 1
  • 1
  • 1
  • See: [Using NetCat (nc) running in the background](http://siderite.blogspot.com/2010/03/using-netcat-nc-running-in-background.html) – Greg Kopff Aug 03 '12 at 11:18

3 Answers3

3

I'd use screen. If you run each end in a screen session, you can detach it (Ctrl-d) and log out while leaving it running.

Ben Jencks
  • 1,351
  • 8
  • 13
1

To start a process that is both backgrounded and detached form the running shell, you can do the following (using your example):

(pg_dumpall -v  | nc 192.168.3.95  4000 &)

pstree comes in handy here, for verifying that it's detached (or ps -ejH if you don't have it)

SmallClanger
  • 8,947
  • 1
  • 31
  • 45
1

Make sure to include '-d' on your listening daemon, I've run into problems with netcat, even in listen mode, not forking because it expects stdin.

ampledata
  • 106
  • 4