LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using ftp to transfer files from one server to another (https://www.linuxquestions.org/questions/linux-newbie-8/using-ftp-to-transfer-files-from-one-server-to-another-4175563183/)

hruday 01-06-2016 02:13 AM

Using ftp to transfer files from one server to another
 
I am using FTP to login into remote server to copy files

#!/bin/sh

DUMPS=/root/exp/
TMP=/root/tmp

find $DUMPS/*.sql.zip -type f -mtime +15 -exec cp {} $TMP \;

cd $TMP

# FTP Login

HOST=ipaddr
USER=usrname
PASS=passwrd123
REM_DIR=/home/bkpdir

for f in *; // the second time when i run the script
do
echo "Uploading file via FTP:" $f

ftp -in $HOST <<EOF

quote USER $USER
quote PASS $PASS

cd $REM_DIR
put $f
bye
EOF

done



It works fine but the problem i have to run this daily to copy files which are 15 days old in dumps dir.

There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?

pan64 01-06-2016 02:41 AM

duplicate of https://www.linuxquestions.org/quest...ct-4175562924/

hruday 01-06-2016 02:47 AM

Quote:

Originally Posted by pan64 (Post 5473780)

hi pan64
as expect was not working for me I created script using ftp.

suicidaleggroll 01-06-2016 10:13 AM

Quote:

Originally Posted by hruday (Post 5473771)
There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?

Use keys or expect with rsync. I posted a complete and working example of using expect for this purpose in your other thread, but I didn't see any response to that post indicating problems or questions. Did you even try it?


All times are GMT -5. The time now is 03:48 PM.