我创建了一个脚本来将源服务器上生成的文件传输到目标服务器,但我想在将文件从源传输到目标时随时替换这些文件。请帮助我实现这一目标。
文件名:
Source file names:
-------------------
EXPORT_TABLE_TEST_27-Aug-2020_02.dmp
EXPORT_TABLE_TEST_27-Aug-2020_01.dmp
我想实现这样的目标,并且服务名称(TEST,UAT)和日期在不同服务器上将保持不同。请帮助我,我将不胜感激。提前致谢。
Target Files:
------------------
EXPORT_TABLE_UAT_28-Aug-2020_02.dmp
EXPORT_TABLE_UAT_28-Aug-2020_01.dmp
使用的代码。
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