0

I have created a script to transfer the files generated on source server to target server but I want to replace the files on the go while transferring the file from source to target. Please help me in achieving this.

File Name:

Source file names:
-------------------
EXPORT_TABLE_TEST_27-Aug-2020_02.dmp
EXPORT_TABLE_TEST_27-Aug-2020_01.dmp

I want to achieve something like this and the Service name(TEST,UAT) and dates will keep differing on different server. Please help me, it will be deeply appreciated. Thanks in Advance.

Target Files:
------------------
EXPORT_TABLE_UAT_28-Aug-2020_02.dmp
EXPORT_TABLE_UAT_28-Aug-2020_01.dmp

Code Used.

        if [ ! -d "${LOC1}" ]; then
                echo
                echo -e "\033[32;5mERROR: THE PROVIDED LOCATION IS NOT EXIST !\033[0m"
                echo
                echo "Please Enter the location where your EXPORTED FILES [DUMPFILES] are saved: [ENTER THE FULL DIRECTORY PATH]"
                echo "==========================================================================="
        else
                 echo
        for FILES in `find $LOC1 -type f -ctime -1`
                do
                                echo "List of  Files generated for last 24 HRS is $FILES"
                                echo ""
                                echo "=========================================================================================================="
                                echo " Transferring this Files from "$HOSTNAME" to "$DEST_SERVER" server. "
                                echo "=========================================================================================================="
                                echo ""
                               sshpass -e scp $FILES $USER@$DEST_SERVER:/$DEST_DIR/
            done
                            echo ""
                            echo "Transfer of files completed."
            break
     fi

done

furas
  • 239
James
  • 3

0 Answers0