As you know bash can be a little picky with certain spaces, so please try and not change the script much unless you know what you are doing.
You need to create a file with the source below and give execution permissions.
For example:
touch script.sh
then add the source code with VI or any editor and finally
chmod a+x script.sh
You are free to use the script, in combination with the crontab you can automate you server to upload any specific files or folders you might need to back up to a remote ftp server. I currently use this same script on multiple servers with great success.
I would appreciate you leaving my name on the Script ( ego talking )
The Script Below:
# =====================================
# SCRIPT by Felipe Cruz for SHDaemon.com
# please respect the reference above
# =====================================
# -- CONFIGURE VALUES --
ftpserv="10.0.0.1" # - Ftp server ip
ftpusr="ftpuser" # - ftp user
ftppass="mypass" # - ftp password
remotefolder="" # - remote storage location
localfolder="/home/myfiles" # - where are my files
# -- DO NOT CHANGE FROM DOWN BELOW --
recorrido=`ls $localfolder`
for i in $recorrido; do
echo "Copying archive $i , proceso $$ , use CTRL+C to abort "
echo "Information:"
echo `file $localfolder/$i`
# -- Comandos FTP --
ftp -i -v -n $ftpserv <<ENDFTP
user $ftpusr $ftppass
binary
send $localfolder/$i $remotefolder/$i
bye
ENDFTP
echo "Completed upload for $i"
echo ""
sleep 3
done
echo "FINISHED"
Thanks for share nice blog......
Posted by: FTP Brute | 12/16/2009 at 01:38 AM