Rsync and Move files

I Have a requirement where i have to sync two directories one on source location server A and other on destination location server B
as i do not have ssh access from server A----------->B I am doing rsync from server B,
The Requirement is as follows

  1. Two directories on the source and destination have to be synced
  2. After that they have to be moved to different directory on the source server i.e server A
  3. In step 1 only files having extension .tif have to be synced and the files other than .tif have to be synced with timestamp
#!/bin/bash
sourcef="root@192.168.83.8:/Somedirectory/*.*"
datelog=`date +%Y-%m-%d:%H:%M:%S`
destination="/mnt/xyz/"
/usr/bin/sshpass -p 'password' /usr/bin/rsync  --include="*.tif" --exclude="*" -avzh  $sourcef $destination --log-file=/var/log/rsync.log

This is incomplete what is needed is the the files other than .tif have to be timestamp and synced to destination later the it has to be moved to a folder in source server A.
The tif files does not necessarily end with *.tif it can be like *.tif.sometext

With sshpass you are breaking the security protocols that ssh and similar tools require. This is never a good thing.

You say that you don't have ssh access, but you know a password. Do you mean that the account does not allow you to get to a shell prompt if you use ssh? Can you not ask the administrator of the server you connect to? They should be able to enable access with SSH-key authentication.

Another alternative might be to set the variable RSYNC_PASSWORD or use the --password-file option. Would they not be better? Is that better than sledge-hammering your way on?

Robin

I can change that but the main thing here is the script which i need to work on to make the work done i can ssh server B from from A password less

#!/bin/bash
sourcef="/Somedirectory/*.*"
datelog=`date +%Y-%m-%d:%H:%M:%S`
destination="root@192.168.83.7/mnt/xyz/"
 /usr/bin/rsync  --include="*.tif" --exclude="*" -avzh  $sourcef $destination --log-file=/var/log/rsync.log

Need the below required work to be done

The Requirement is as follows

  1. Two directories on the source and destination have to be synced
  2. After that they have to be moved to different directory on the source server i.e server A
    3.In step 1 only files having extension .tif have to be synced and the files other than .tif have to be synced with timestamp

The tif files does not necessarily end with *.tif it can be like *.tif.sometext

Can you explain in more detail what you want to happen when you say

.

rsync supports two different methods to determine if files have changed and need to be transfered. By default a "quick check" is done using the files size and timestamp, if --checksum option is set then a 128-bit checksum is calculated for each file that has a matching size.

Are you after a full checksum comparison on *.tif* files and filesize + timestamp for everything else?

#bin/bash -x
source1="/home/u02/Oracle"
dest1="/home/u02/Oracle/LOG"
chmod 777  $source1/*.tif
chmod 777  $source1/*.txt
/usr/bin/scp  $source1/*.tif  192.168.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension tif on `date`" >> /var/log/croncopy.txt
        fi
/usr/bin/scp  $source1/*.txt  10.83.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension txt on `date`" >> /var/log/croncopy.txt
        fi
/usr/bin/scp  $source1/*.TIF  10.83.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension TIF on `date`" >> /var/log/croncopy.txt
        fi

exit

---------- Post updated at 02:52 AM ---------- Previous update was at 02:51 AM ----------

#!/bin/bash
source1="/home/u02/Oracle"
dest1="/home/u02/Oracle/LOG"
dirdatelog=`date +%Y%m%d%H%M%S`
mkdir $dest1/$dirdatelog
movedest="$dest1/$dirdatelog/"
mv $source1/*.tif $movedest > /dev/null 2>>/var/log/errormove.txt
mv $source1/*.txt $movedest  > /dev/null 2>>/var/log/errormove.txt
mv $source1/*.TIF $movedest  > /dev/null 2>>/var/log/errormove.txt
exit

---------- Post updated at 02:53 AM ---------- Previous update was at 02:52 AM ----------

The two above scripts will copy initially and later move the files to the destination folder