Wednesday, November 11, 2015

Bash to copy files from AWS to local drive

#!/bin/bash

# Copy from AWS
# Password based ssh access, but downside is disclose plain text password. Better use ssh key pair based access
# sshpass -p "Password" scp -pv root@qqec2.tklapp.com:~/AuctionResults/*.pdf ./
rsync --checksum qqec2:~/AuctionResults/*.pdf ./
echo "Done synch with AWS"
ssh qqec2 "if [ ! -d 'AuctionResults-Bkup' ]; then mkdir -v AuctionResults-Bkup; echo 'Created folders that doesnot exist';fi;
#ssh qqec2 "if [ ! -d "AuctionResults-Bkup" ]; "
#"then mkdir -v AuctionResults-Bkup; "
#"echo "Created folders that doesnot exist";"
#"fi;"
#"cp -vp AuctionResults/*.pdf AuctionResults-Bkup/""
echo "Done moving all download pdf files to bkup folder on AWS"

No comments: