I recently just wrote a script for backing up a remote Git server onto my local server. However, I have about 45 different repositories so this involves copying and pasting my code 45 times and changing the repo names for each one. Is there a simpler way to accomplish what I am trying to do? (In terms of editing my script) Here is my code:
sudo rm -rf /home/<user>/<localRepoFolder>
git clone --mirror git@<remoteIP:repo> /home/<user>/<localRepos>/<repo>/$(date +%Y%m%d)
cd /home/<user>/<localRepos>/<repo>/$(date +%Y%m%d)
git remote rm origin
git remote add origin git@<localIP>
git push origin --all
git push --tags
Also, how would I go about editing the script so that I can save the 2 latest backups in case something breaks after removing them from my local server? If/else statement dealing with the timestamp?