LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change a line in a rsync script and send the file changed (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-a-line-in-a-rsync-script-and-send-the-file-changed-845350/)

danndp 11-19-2010 11:51 AM

How to change a line in a rsync script and send the file changed
 
Hello my friends,

I'm configuring an rsync between 2 machines, A_Server --> B_Server, using the following script:

Code:

#!/bin/bash
#
# Script de backup a través de Rsync desde RMP-1 hasta RMP-2.
#
# Si se produce algún error en cualquier momento abortar.
#set -e

DATOS="/tmp/prueba.txt"
EXCLUDES=
OPTS="-vv --relative --delete --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES -a"
RSERVER="rsync://A_Server@192.168.1.4/A_Server/"
export RSYNC_PASSWORD=1234

#Este script sincroniza los datos de Asterisk de RMP-1 a RMP-2 a través
#del servicio rsyncd. Los datos se guardan en RMP-2 en la carpeta
#/home/RMP-1/.
"
echo
echo "Copiando datos ..."
echo "rsync $OPTS $DATOS $RSERVER"
rsync $OPTS $DATOS $RSERVER
echo "OK"

echo
echo "Hora Fin: $(date)"
echo "=)"

The Rsyn is working OK. What i need is to change one of the lines of the /tmp/prueba.txt before sending it to the remote machine (obviously not changing the file in the local machine), i mean, send prueba.txt to the remote machine deleting one line and adding another one...how can i do this????

sed is a good choice, but no clue how to put all together in the same script...i would appreciate your help :)

BEST REGARDS!!!

fcintron 11-20-2010 09:26 AM

Quote:

Originally Posted by danndp (Post 4164565)
Hello my friends,

I'm configuring an rsync between 2 machines, A_Server --> B_Server, using the following script:

Code:

#!/bin/bash
#
# Script de backup a través de Rsync desde RMP-1 hasta RMP-2.
#
# Si se produce algún error en cualquier momento abortar.
#set -e

DATOS="/tmp/prueba.txt"
EXCLUDES=
OPTS="-vv --relative --delete --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES -a"
RSERVER="rsync://A_Server@192.168.1.4/A_Server/"
export RSYNC_PASSWORD=1234

#Este script sincroniza los datos de Asterisk de RMP-1 a RMP-2 a través
#del servicio rsyncd. Los datos se guardan en RMP-2 en la carpeta
#/home/RMP-1/.
"
echo
echo "Copiando datos ..."
echo "rsync $OPTS $DATOS $RSERVER"
rsync $OPTS $DATOS $RSERVER
echo "OK"

echo
echo "Hora Fin: $(date)"
echo "=)"

The Rsyn is working OK. What i need is to change one of the lines of the /tmp/prueba.txt before sending it to the remote machine (obviously not changing the file in the local machine), i mean, send prueba.txt to the remote machine deleting one line and adding another one...how can i do this????

sed is a good choice, but no clue how to put all together in the same script...i would appreciate your help :)

BEST REGARDS!!!


There are two utilities called diff and patch. With diff you can find the diferrences between two files. And patch is used to apply these differences.

There is and explanation in this link.

http://stephenjungels.com/jungels.ne...n-minutes.html


Regards


All times are GMT -5. The time now is 05:10 AM.