| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # ==> Script by James R. Van Zandt, and used here with his permission. |
| 3 | |
| 4 | # ==> Comments added by author of this document. |
| 5 | |
| 6 | |
| 7 | HERE=`unamescip-shell system . . uname. -n` # ==> hostname |
| 8 | THERE=bilbo |
| 9 | echoscip-shell system . . echo. "starting remote backup to $THERE at `datescip-shell system . . date. +%r`" |
| 10 | # ==> `date +%r` returns time in 12-hour format, i.e. "08:08:34 PM". |
| 11 | |
| 12 | # make sure /pipe really is a pipe and not a plain file |
| 13 | rmscip-shell system . . rm. -rf /pipescip-shell filesystem . . `/pipe`. |
| 14 | mkfifoscip-shell system . . mkfifo. /pipescip-shell filesystem . . `/pipe`. # ==> Create a "named pipe", named "/pipe" ... |
| 15 | |
| 16 | # ==> 'su xyz' runs commands as user "xyz". |
| 17 | # ==> 'ssh' invokes secure shell (remote login client). |
| 18 | suscip-shell system . . su. xyz -c "ssh $THERE \"cat > /home/xyz/backup/${HERE}-daily.tar.gz\" < /pipe"& |
| 19 | cd /scip-shell filesystem . . `/`. |
| 20 | tarscip-shell system . . tar. -czf - bin boot dev etc home info lib man root sbin share usr var > /pipescip-shell filesystem . . `/pipe`. |
| 21 | # ==> Uses named pipe, /pipe, to communicate between processes: |
| 22 | # ==> 'tar/gzip' writes to /pipe and 'ssh' reads from /pipe. |
| 23 | |
| 24 | # ==> The end result is this backs up the main directories, from / on down. |
| 25 | |
| 26 | # ==> What are the advantages of a "named pipe" in this situation, |
| 27 | # ==>+ as opposed to an "anonymous pipe", with |? |
| 28 | # ==> Will an anonymous pipe even work here? |
| 29 | |
| 30 | # ==> Is it necessary to delete the pipe before exiting the script? |
| 31 | # ==> How could that be done? |
| 32 | |
| 33 | |
| 34 | exit 0 |