1843990 Members
1637 Online
110226 Solutions
New Discussion

Re: Script help

 
Isaac_4
Frequent Advisor

Script help

HI

I need help to made a script that copy to one server to a other some file, but only ineed copy only the new ones. no all files
who can do that with out copy all files ?

example:

srv1 /tmp/data1, data2 etc.. copy svr2 /tmp/data2 the data2 is data new for this day

Thank You !!!
The time is gold
5 REPLIES 5
Sandman!
Honored Contributor

Re: Script help

Looks like rsync will be best suited for this job...since it copies only new and changed files instead of all thus saving network bandwidth. See the man page for rsync(1).

cheers!
Geoff Wild
Honored Contributor

Re: Script help

Or use the built in command rdist:

Here's how I sync /home/bwpadm user to DR site:

From cron:

15 01 * * * /app/admin/drp/update-binaries.sh >/tmp/update-binaries.cron 2>&1

#! /bin/sh

# Keep the DRP copy of the bwpadm up-to-date.
# Currently the files are in:
#
# /home/bwpadm/DR
#
# See the rdist(1M) distfile for a list of exclusions.

DRPDIR=/app/admin/drp
DRPHOST=svr102

HOST=`/usr/bin/uname -n`
mount | grep /home > /dev/null 2>&1
if [ $? -eq 0 ]
then
/usr/sbin/vgexport -p -s -v -m /home/bwpadm/DR/vg10.map /dev/vg10
( su - bwpadm -c "rdist -f $DRPDIR/distfile bwpadm"; ) 2>&1 |\
tee $DRPDIR/drp.log 2>&1 |\
mailx -s "bwpadm DRP rdist output" sysadm
fi

# cat /app/admin/drp/distfile
BWPDR = ( svr102 )

#
# File systems to be copied over to the DR host.
# Don't use -R in install - so as not to remove files on destination host
BWPADM = /home/bwpadm

bwpadm: ( ${BWPADM} ) -> ( ${BWPDR} )
install -w ;



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Siddhartha M
Frequent Advisor

Re: Script help

Muthukumar_5
Honored Contributor

Re: Script help

Why can not you use NFS for this requirement simply?

Or else write a script to find files which are new today and put into a file called /tmp/files2copy-svr2.

First copy the file and then get the files available in that file.

Else use rsync for this.

--
Muthu
Easy to suggest when don't know about the problem!
bebravo
New Member

Re: Script help

Hi,

you can use the find command with -ctime, -mtime, atime parameters then copy it to the other server using scp/rcp/ftp/sftp etc...

your command would look like this.

find /tmp -name "data?" -mtime +1 -exec scp {} user@svr2:/tmp/{} \};

good luck ..hope this helps..

"We are the product of the choices we make, the choice is yours!"