Linux Folder To FTP

Kendi linux sunucularımda kullandığım script..

#General
WINDOWS_SERVER=serverip
LOCALDIR=/folder/path/
FILENAME=`date -d ‘1 day ago’ +%Y-%m-%d`.zip
YESTERDAY=`date -d ‘1 day ago’ +%Y-%m-%d`
LOG=log.txt

# Folder Zip
cd $LOCALDIR
zip -r $FILENAME $YESTERDAY >> log.txt
# Send FTP
ftp -in << EOF
open $WINDOWS_SERVER
user username password
mkdir “`date +%Y`”
cd “`date +%Y`”
mkdir “`date +%B`”
cd “`date +%B`”
mkdir K1
cd K1
binary
lcd $LOCALDIR
send $FILENAME
close
EOF

#mail send
#SUBJECT=”`date -d ‘1 day ago’ +%Y-%m-%d` information”
mutt -s “`date -d ‘1 day ago’ +%Y-%m-%d` information” -a /folder/path/log.txt [email protected] -c [email protected] tr < /template/information.txt

# after folder delete
cd $LOCALDIR
rm -rf $LOCALDIR/$YESTERDAY
rm -rf $LOCALDIR/$FILENAME
rm -rf $LOCALDIR/log.txt

No Comments

Post a Comment