I need help with creating a pipe, I found this code online but not exactly sure what different parts are doing.
Will someone be able to help me with explaining what code is doing?
Also what I want is to have everything the same directory. Meaning I am working in directory:
I want to keep everything in Testing directory.
#!/bin/bash
HERE=`uname -n` # Will I be able to add the directory here
THERE=bilbo # What is this creating?
echo "starting remote backup to $THERE at `date +%r`"
# ==> `date +%r` returns time in 12-hour format, i.e. "08:08:34 PM".
e
rm -rf /pipe
mkfifo /pipe # ==> Create a "named pipe", named "/pipe".
#What is this doing too?
su xyz -c "ssh $THERE \"cat >/home/xyz/backup/${HERE}-daily.tar.gz\" < /pipe"&
cd /
#This too?
tar -czf - bin boot dev etc home info lib man root sbin share usr var >/pipe
exit 0
Is that what you want?... If you tell us what you are trying to do, we can cut to solving your problem much faster. For example, do you have to have a named pipe?
#!/bin/bash
HERE=`uname -n` # Stores the node name of the host server
THERE=<SERVER WHERE YOU WANT TO KEEP THE BACKUP> #Server on which you want to store the backup
MYDIR=/home/users/Bashwork/Testing
PIPE=${MYDIR}/pipe
echo "starting remote backup to $THERE at `date +%r`"
# ==> `date +%r` returns time in 12-hour format, i.e. "08:08:34 PM".
cd ${MYDIR}
rm -rf ${PIPE}
mkfifo ${PIPE} # ==> Create a "named pipe", named "/pipe".
#What is this doing too?
## Assuming you want to create backup from your own user, USER
su ${USER} -c "ssh $THERE \"cat >/home/xyz/backup/${HERE}-daily.tar.gz\" < ${PIPE}"&
cd /
#This too?
tar -czf - bin boot dev etc home info lib man root sbin share usr var >${PIPE}
## This is writing the new tar ball (backup of above mentioned folder) and writing on the PIPE
exit 0
If you want to keep the backup in the same directory and that means same server, why u want to create pipes and all?
It can be easily accomplish by simple tar and gzip command.
it will be much easier doing this:
#!/bin/bash
HERE=`uname -n` # Stores the node name of the host server
MYDIR=/home/users/Bashwork/Testing
echo "starting backup at `date +%r`"
# ==> `date +%r` returns time in 12-hour format, i.e. "08:08:34 PM".
TARBALL="${MYDIR}/${HERE}-daily.tar.gz"
cd /
#This too?
tar -czf - bin boot dev etc home info lib man root sbin share usr var | gzip -9c - >${TARBALL}
exit 0