Files
options_backtester/data_scraper/scripts/backup.sh
T
Juan Pablo Amoroso 34925b8bee Added data_scraper
2019-05-13 15:28:23 -03:00

42 lines
900 B
Bash
Executable File

#!/bin/bash
## This script downloads stock options data,
## veryfies zipfile integrity, saves md5 signature
## and uploads them to S3.
## To run, pass a list of files to download:
## $> ./backup.sh files.txt
TMPDIR=tmp
NOW=$(date +"%m-%d-%Y-%H%M%S")
RETRY="${NOW}.txt"
MD5SUMS=md5sums.txt
mkdir -p $TMPDIR
while read filename
do
echo "Downloading file $filename to $TMPDIR"
wget --quiet -P $TMPDIR "ftp://l3_hdall:JKNRH7LYXV@ftp.deltaneutral.com/${filename}"
newpath="$TMPDIR/$filename"
echo "Verifying zipfile $newpath"
if unzip -t -q $newpath
then
echo "File check OK"
else
echo "ERROR: File check failed for $newfile"
echo $filename >> $RETRY
rm $newpath
continue
fi
echo "Appending md5 sum for $f"
md5sum $newpath >> $MD5SUMS
echo "Copying $newpath to S3 bucket"
rclone copy -v $newpath longueduree:longueduree
echo "Deleting $newpath"
rm $newpath
done <$1