feat: git weekly backups
This commit is contained in:
parent
a2e0884383
commit
01e95df06b
2 changed files with 44 additions and 16 deletions
|
|
@ -25,15 +25,15 @@ echo $repo_urls
|
|||
echo "----\n"
|
||||
|
||||
#Cloning each repo to destdir
|
||||
i=0;
|
||||
finished=false;
|
||||
while ! $finished
|
||||
repo_idx=0;
|
||||
repo_finished=false;
|
||||
while ! $repo_finished
|
||||
do
|
||||
i=$(($i+1));
|
||||
repo=$(awk "{print \$$i}" <(echo $repo_urls))
|
||||
repo_idx=$(($repo_idx+1));
|
||||
repo=$(awk "{print \$$repo_idx}" <(echo $repo_urls))
|
||||
if [ "$repo" = "" ]
|
||||
then
|
||||
finished=true
|
||||
repo_finished=true
|
||||
else
|
||||
#Retrieve repo name for folder
|
||||
repo_name="$(awk -F/ '{print $5}' <(echo $repo))"
|
||||
|
|
@ -42,16 +42,31 @@ do
|
|||
#Remove quotes from user_username
|
||||
username=${user_username%\"}
|
||||
username=${username#\"}
|
||||
#Clone repo
|
||||
#TODO: what do if repo already exists? if it!
|
||||
#Clone or rebase repo
|
||||
if [ -e "$REPO_DIR$repo_name" ]
|
||||
then
|
||||
echo "REPO: $repo_name"
|
||||
git -C "$REPO_DIR$repo_name" fetch --all
|
||||
#git -C "$REPO_DIR$repo_name" rebase --update-refs
|
||||
git -C "$REPO_DIR$repo_name" fetch -t --all
|
||||
branch="$(git -C "$REPO_DIR$repo_name" branch | awk '{print $2}')"
|
||||
git -C "$REPO_DIR$repo_name" rebase $branch --onto origin/$branch
|
||||
else
|
||||
git clone https://$user_username:$AUTH_TOKEN@$GIT_DOMAIN/$username/$repo_name /home/$USER/pihanepi/datamount/gitbackup/$repo_name --recurse-submodules
|
||||
git clone https://$user_username:$AUTH_TOKEN@$GIT_DOMAIN/$username/$repo_name /home/$USER/pihanepi/datamount/gitbackup/$repo_name --recurse-submodules
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#NOTE: Cool git formatting and same loop to operate on all remote branches
|
||||
#branches="$(git -C $REPO_DIR$repo_name branch -r --format='%(refname:short)' | awk -F/ '{if ($2) print $2;}')"
|
||||
#branch_idx=0;
|
||||
#branch_finished=false;
|
||||
#while ! $branch_finished
|
||||
#do
|
||||
# branch_idx=$(($branch_idx+1));
|
||||
# branch=$(awk "{print \$$branch_idx}" <(echo $branches))
|
||||
# if [ "$branch" = "" ]
|
||||
# then
|
||||
# branch_finished=true
|
||||
# else
|
||||
# git -C "$REPO_DIR$repo_name" rebase $branch --onto origin/$branch
|
||||
# fi
|
||||
#done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue