Article 5919T How to conjoin the rsync commands in this script?

How to conjoin the rsync commands in this script?

by
Pedroski
from LinuxQuestions.org on (#5919T)
rsync is a marvellous program!

I use it to back up everything over my home network. I save everything important to an old laptop.

With help from here, I managed to get a bash script working to fetch files from my webpage to my laptop. This is is a variation on that, to get pairs of students for an oral assignment. It works fine, thanks to LQ!

I'm just wondering how to conjoin the 3 calls to rsync into 1 call? The whole script is below. These are the lines I would like to join into 1 call:

Code:rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE1* "${pairsData1}"

rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE2* "${pairsData2}"

rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE3* "${pairsData3}"If you can see any other improvements, I will be glad to hear them!

Code:#! /bin/bash
echo "This script should 1. move older files to backup then 2. get the pairs files you want from the webpage, 3. write the data to an excel file, 1 for each class"

filesPairs1="/home/pedro/winter2020/19BE/pairsFiles/19BE1/*" # local machine
filesPairs2="/home/pedro/winter2020/19BE/pairsFiles/19BE2/*" # local machine
filesPairs3="/home/pedro/winter2020/19BE/pairsFiles/19BE3/*" # local machine

oldfilesPairs1="/home/pedro/winter2020/19BE/oldpairsFiles/19BE1/" # local machine
oldfilesPairs2="/home/pedro/winter2020/19BE/oldpairsFiles/19BE2/" # local machine
oldfilesPairs3="/home/pedro/winter2020/19BE/oldpairsFiles/19BE3/" # local machine

echo "First, BACKUP: move present content of /home/pedro/winter2020/19BE/pairsFiles/19BEX to /home/pedro/summer2020/19BE/oldpairsFiles/19BEX"

mv $filesPairs1 $oldfilesPairs1
mv $filesPairs2 $oldfilesPairs2
mv $filesPairs3 $oldfilesPairs3

echo "Files backed up!"

pairsData1="/home/pedro/winter2020/19BE/pairsFiles/19BE1" # local machine
pairsData2="/home/pedro/winter2020/19BE/pairsFiles/19BE2" # local machine
pairsData3="/home/pedro/winter2020/19BE/pairsFiles/19BE3" # local machine

# server data

user="myusername" # my webpage user name
server="123.456.789.123" # my ip address

path1="~/public_html/19BEpairs" # webhost /19BEpairs get the pairs files

echo "Second, get the pairs files for 19BE1 from the remote server to this computer."

rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE1* "${pairsData1}"

echo "Third, get the pairs files for 19BE2 from the remote server to this computer."

rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE2* "${pairsData2}"

echo "Fourth, get the pairs files for 19BE3 from the remote server to this computer."

rsync -av --progress -e 'ssh -i ~/.ssh/godaddy5_rsa' $user@$server:${path1}/*19BE3* "${pairsData3}"

echo "Got the pairs data files!"

echo "Fifth, put the data from the downloaded text files in an excel."
echo "Calling getPairs2020v1.py to write the pairs to an excel."
echo " "

/home/pedro/winter2020/19BE/python/getPairs2020v1.py

echo "Pairs inserted in an excel, all done!"

echo "pairs excel for all 19BE classes made, all done, till next time!"
echo "Bye bye!"latest?d=yIl2AUoC8zA latest?i=8qV1J3WxPUE:mKL6XwUQfyY:F7zBnMy latest?i=8qV1J3WxPUE:mKL6XwUQfyY:V_sGLiP latest?d=qj6IDK7rITs latest?i=8qV1J3WxPUE:mKL6XwUQfyY:gIN9vFw8qV1J3WxPUE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments