Help needed with Content synchronization script using rsync
Hi All,
I need a .sh script which serves the below purpose. It would be of great help.
I am unable to perform the second need of mapping texts within the file and updating only those contents.
For Eg: There is a html file containing link abc.com. This should be replaced with xyz.com link in the destination folder.
##########################################
1)content sync from source to target machine, based on a extensive list of directories and hostnam/ip
2)search and replace of the mapped texts from source to target
3)replacement should be only in changed/updated files and to a configurable set of file extensions
#######################################
Below is my script workthrough as of now:
Code:
#############################################
#!/bin/sh
#!/usr/bin/perl
##################################################################################
#
#
# This script is used to sync the contents from source directory of local #machine
# to destination directory of target machine.
#
##################################################################################
################################################################################
# Logging directory
################################################################################
LOGDIR="Path to logging directory"
################################################################################
# RSync binary location
################################################################################
rsync="/opt/mw/rsync-2.6.6/bin/rsync"
################################################################################
# RSync binary location on remote server
# this is only used when source and target directories are on different servers
# otherwise it should be same rsync value
################################################################################
rsync_path="/opt/mw/rsync-2.6.6/bin/rsync"
################################################################################
# For Content mapping below mentioned directory paths and hostnames are required
################################################################################
SOURCEDIR="Path to Source Directory on Local Machine"
TARGETDIR="Path to Target Directory on Remote Machine"
BACKUPDIR="Path to Backup Directory"
TARGETSERVER="Hostname"
TargetUser="Username"
LOGFILE="Path to Log file"
Rsync_Options = "--recursive --times --archive --verbose --update --links --checksum --progress --delete"
#-v, --verbose increase verbosity
#-a, --archive archive mode
#-r, --recursive recurse into directories
#-u, --update skip files that are newer on the receiver
#-t, --times preserve modification times
#-l, --links copy symlinks as symlinks
#-c, --checksum skip based on checksum, not mod-time & size
#--dry-run
#rsync --recursive --times --archive --verbose --update --links --checksum --progress --delete
################################################################################
# RSync filters
# file/folders mentioned in the filter will be skipped for synchronization
# for more details on rsync filter read rsync documentation
################################################################################
rsync_filter="- .backup/"
#################################################################################
# Check if the log file exists
################################################################################
if [ ! -e $LOGFILE ]; then
touch $LOGFILE
fi
if [ ! -d $TARGETDIR ]; then
echo "Log destination directory doesn't seem to exist. Please investigate"
exit 2
fi
echo $'\n\n' >> $LOGFILE
#####################################################################
#
# Gather a list of the files from source directory and the remote directory.
# It finds the file differences and copy the files to the destination directory.
# Only missing files are copied.
#
#####################################################################
#for i in `find $SOURCEDIR -type f`
#do
rsync $Rsync_Options -e ssh $SOURCEDIR/ $TargetUser@$TARGETSERVER :$TARGETDIR/
#done
echo "Sync Completed at:`/bin/date`" >> $LOGFILE
How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm.
Kindly help.
Thanks.
To be more precise,
I want to create a script which matches the today's date with server's date format, if matches then creates the... (2 Replies)
I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location
I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
HI
i am running a shell script in cron and storing the output of that script in a file say test.then i am copying the content of test to test1 and i will send the output of test to some email ids using mutt. Next time when the script executes i am comparing the contents of test and test1 and... (3 Replies)
Hi everyone!
I wonder about the rsync. The purpose I just want:
synchronization from server 1 to server 2 by rsync, example:
Node 1: /app/logs/*
Node 2: /app/logs/*
in Node 1 when I used rsync -aru /app/logs/ node2:/app/logs/, then everything will be copied and update to node 2. But,... (1 Reply)
Dear all,
I am synchronizing some files on 2 hosts.
host2 is a backup server of host1, but can have some more up to date files.
I use on host2:
rsync -auv usrer@host1:/Source_Dir Dest_DirOption -u (update) will copy and replace the newest files from host2 to host1.
Before this is done I... (1 Reply)
Hi
I've searched for it for few hours now and i can't seem to find anything working like i want. I've got webpage, saved in file par with form like this:
<html><body><form name='sendme' action='http://example.com/' method='POST'>
<textarea name='1st'>abc123def678</textarea>
<textarea... (9 Replies)
Good day all,
I need your help in editing a rsync script that I am trying to write and using ksh shell.
I want to add multiple patterns --include and --exclude options with variable inputs called SID. I have created two files and named them N1 and N2 and created subfiles in each one
In... (4 Replies)
How can i combine the below two rsync commands into one:
rsync -auvL --delete /etc /usr/local/MediaServer /mnt/bak/livecore/filesystem.0 > /tmp/backup_log/rsync.log 2>&1
and
rsync -auv --delete --exclude='live/public_html/video' --exclude='live/public_html.old' /var/www... (0 Replies)