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?
Last edited by hruday; 01-06-2016 at 02:46 AM.
|