Simple script:
#!/bin/bash
remote_ssh_account="depesz@localhost"
directory_to_tar=pgdata
exec nice tar cf - "$directory_to_tar" | \
tee >(
md5sum - | \
ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-MD5-2012-03-13.tar'
) | \
ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-data-2012-03-13.tar'
Theoretically it should deliver the data and checksum, to remote machine.
But somehow the tee fails with:
tee: standard output: Resource temporarily unavailable
Did strace, but nothing came out of it. I see both ssh started, and tee writing to both of them, but only the pipe to ( md5sum | ssh ) gets data - strace of the ssh "data" doesn't get any data, and after 5 seconds tee shows the error.
Aside from this all works. 2 connections are established, tar works, md5sum and its delivery works.
strace
front, trystrace -fF
. Works like a champ for me. – BMDan Mar 14 '12 at 20:14strace -ff -o strace.log -s 512 ./z.sh
– user13185 Mar 14 '12 at 20:25-fF
is the same as-f -F
. The-F
is actually unneeded on most of the systems I work on, but it (tries to) follow vforks on older versions of strace, and has no effect on newer ones, but it doesn't hurt.-ff
ends up writing a bunch of files (one per PID) that you then have to collate back into a sensible timeline, so I avoid it in the vast majority of situations. That said,-ff
should work, but the output files will be oddly-named. – BMDan Mar 15 '12 at 12:55