Visit Our UNIX and Linux User Community


How to sync without rsync?


 
Thread Tools Search this Thread
Operating Systems Solaris How to sync without rsync?
# 1  
Old 04-16-2012
How to sync without rsync?

rsync for solaris seems to be a spotty beast. It's not installed by default. I facing a problem where I didn't have root access to be able install rsync. I did have ssh access and was able to configure the authorized keys so that no password was required to connect from one server to another. What I required was a means of copying the contents of one directory to another directory on another server. Others may find this useful, so here it is:
Code:
#/bin/bash

##############################################################
#
# This script is used to copy the contents of /export/home/oracle/reports
# to remoteusr@remoteserver into the directory /export/home/myuser/data/reports
#
#
##############################################################

LOGFILE="/export/home/digi/log/backupscript.log"
DIR="/export/home/oracle/reports"
RSERVER="remoteserver"
RDIR="/export/home/myuser/data/reports"
RUSER="remoteusr"
cd "$DIR"


#####################################################################
#
# Gather a listing of the files from server directory and the remote directory.
# It finds the file differences and copy the files to the destination directory.
# Only missing files are copied. Sub directories are not considered
#####################################################################


for i in `find $DIR -type f`
do

# Strip out the directory garbage leaving only the file name and see if it exists on the remote server
FILE=`echo $i|awk 'BEGIN {FS="/"} {print $6}'`
REMOTEFIND=` ssh $RUSER@$RSERVER "find $RDIR -type f -name $FILE" `
if [ ! -n "$REMOTEFIND" ]
then
# The file does not exist so copy it over.
scp $i $RUSER@$RSERVER:$RDIR
echo -e "copied file $i " >> "$LOGFILE"
fi
done

echo -e "Remote backup `date` SUCCESS\n----------" >> "$LOGFILE"

If I was going for efficiency, I would've loaded the directory contents into an array and done array comparisons...but this quick and dirty solution gets the job done.

Last edited by DukeNuke2; 04-16-2012 at 04:32 PM..
# 2  
Old 04-17-2012
nice thank you!
you can also use ssh with tar to copy files from one server to the other, just for info!

Previous Thread | Next Thread
Test Your Knowledge in Computers #648
Difficulty: Medium
Window Maker was written from scratch by Tim Berners-Lee, best known as the inventor of the World Wide Web.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

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)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Rsync from remote machine via ssh and sync by uisng find by modified time

Hi I have a requirement to rsync from remote to local machine via ssh and sync files that are changed in last n hours. pgrep to check if no other sync is running pgrep -f rsync.*/opt > /dev/null || rsync --bwlimit=10000 -avz --delete root@X.X.X.X:/var/source/ /opt/dest/ >> /home/log 2>&1... (0 Replies)
Discussion started by: robo
0 Replies

3. Shell Programming and Scripting

Rsync problem versions out of sync

Hello, I have a report which I am writing as a .tex file, and I am editing from two computers (office and home laptop). I use rsync over ssh connection to synchronise between them and all the rssync commands are written in a Shell script. #synchronise from office computer to home laptop... (2 Replies)
Discussion started by: ajayram
2 Replies

4. AIX

Unable to sync a lv

Hi Please look in to the below issue and advise how to fix the issue. I tried syncvg but it gives me an error. Recently we have upgraded the service pack in this lpar. ========================================================== pmut8# lsvg -l rootvg | grep -i stale paging00 ... (3 Replies)
Discussion started by: newtoaixos
3 Replies

5. Shell Programming and Scripting

rsync - transactional sync with multiple nodes

Hi Everyone, We have a requirement to sync files with multiple nodes. We need to run the rsync sequentially on each node, if one of the node fails we need to recover the files to previous state in all nodes. I know that we have backup option in rsync which takes the backup of files before... (0 Replies)
Discussion started by: MVEERA
0 Replies

6. UNIX for Dummies Questions & Answers

sync directory

Hi, I have directory name as TEST on server1 and same directory TEST on server2 now i need to using these directories as new directories and files will be generated by application in TEST directory daily. I dont have rsync package on server. My approach is by lists all sub-directories... (1 Reply)
Discussion started by: tushar_spatil
1 Replies

7. UNIX for Advanced & Expert Users

How to Sync two servers

Hi All, want to sync. two servers , both are having solaris os. If am updating any thing in one server , it will automatically sync. with the other server . Is it possible , if so den how ? (3 Replies)
Discussion started by: natraj005
3 Replies

8. UNIX for Dummies Questions & Answers

Help with sync

Folks; I have 2 SUSE DNS servers, one will be the master and one will be the slave. we normally update the master when adding any new servers to the DNS list. I'm looking for a way to sync both servers every night, so the slave is updated nightly. I thought of using "rsync" with cron to sync... (1 Reply)
Discussion started by: Katkota
1 Replies

9. Solaris

Sync to Green vs. Separate Sync

Hi all....I have a Sun Ultra2 that I want to use with my PC monitor. I have purchased an adapter that does not work and I was told I need to change my video card setting (if I can) to Separate Sync.....my Monitor product number ends in 1343......I am running SunOS 5.7 ......anyone have any ideas? ... (0 Replies)
Discussion started by: psantinello
0 Replies

10. Solaris

cron sync

hi all , i have a E4900 server cluster that consists of 2 Servers (Cluster1 and cluster2 ) all of my crons are located under /var/spool/cron/crontabs . I am trying to put them on a shared place , so thati dont have to edit both crons on every system . thank you cheers (3 Replies)
Discussion started by: ppass
3 Replies

Featured Tech Videos