aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-03-12 00:15:48 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2012-03-12 00:15:48 +0000
commit069af04a4ae3d48228cd0a03e768425cb534680e (patch)
treeb0442c415b28140029c68b5ccf151c5150380f1f
parent42915d85ecd05b97676d2fb72410c1178c425af9 (diff)
downloadverteco-069af04a4ae3d48228cd0a03e768425cb534680e.tar.gz
7 day rolling upload
-rwxr-xr-xsrc/ftpupload30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/ftpupload b/src/ftpupload
index 05ae60e..54385be 100755
--- a/src/ftpupload
+++ b/src/ftpupload
@@ -9,24 +9,38 @@ PASSWORD=`/usr/bin/ftphelper --password`
SERVER=`/usr/bin/ftphelper --server`
REMOTEDIRECTORY=`/usr/bin/ftphelper --directory`
-# local file to be uploaded
-FILE=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='1 days ago'`"_00_00_00.log"
+# current file to be uploaded
+CURRENTLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='1 days ago'`"_00_00_00.log"
+
+# upload previous 6 days for redundancy
+TWODAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='2 days ago'`"_00_00_00.log"
+THREEDAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='3 days ago'`"_00_00_00.log"
+FOURDAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='4 days ago'`"_00_00_00.log"
+FIVEDAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='5 days ago'`"_00_00_00.log"
+SIXDAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='6 days ago'`"_00_00_00.log"
+SEVENDAYLOG=`/usr/bin/ftphelper --mac`"_"`date +%Y_%m_%d --date='7 days ago'`"_00_00_00.log"
+
+# move file to archive
+mv $CURRENTLOG /var/modbuslog/archive/
# mput is dumb, and if we don't cd to the directory,
# it will try to save file to /var/modbuslog/MAC.....log on ftp remote
-cd /var/modbuslog/
+cd /var/modbuslog/archive/
# login to remote server and upload
-ftp -n -i $SERVER <<EOF
+ftp -n -v -i $SERVER <<EOF
user $USERNAME $PASSWORD
cd $REMOTEDIRECTORY
-mput $FILE
+mput $CURRENTLOG
+mput $TWODAYLOG
+mput $THREEDAYLOG
+mput $FOURDAYLOG
+mput $FIVEDAYLOG
+mput $SIXDAYLOG
+mput $SEVENDAYLOG
bye
EOF
-# move file to archive
-mv $FILE /var/modbuslog/archive/
-
# remove files after 3 months
CLEANUP="/var/modbus/archive/"`/usr/bin/ftphelper --mac`"_"`date +%Y_%m --date='4 months ago'`"*.log"
rm $CLEANUP