From 5f835c69c0f993c589e242cf124987b038b772dd Mon Sep 17 00:00:00 2001 From: Fabio Date: Thu, 3 Jul 2025 18:09:03 +0800 Subject: [PATCH] first commit --- README.md | 32 ++++++++++++++++++++++++++++++++ allgit2tar | 18 ++++++++++++++++++ alltargit2dir | 15 +++++++++++++++ git2tar | 19 +++++++++++++++++++ git2tarAuto | 17 +++++++++++++++++ targit2dir | 15 +++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 README.md create mode 100755 allgit2tar create mode 100755 alltargit2dir create mode 100755 git2tar create mode 100755 git2tarAuto create mode 100755 targit2dir diff --git a/README.md b/README.md new file mode 100644 index 0000000..1cf761f --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Come fare backup di git repository + +verificare file PATH + + echo $PATH + +si dovrebbe trovare anche il path /usr/local/bin/ + +copiare tutti i files + + sudo cp allgit2tar /usr/local/bin/ + sudo cp git2tar /usr/local/bin/ + sudo cp targit2dir /usr/local/bin/ + sudo cp git2tarAuto /usr/local/bin/ + sudo cp alltargit2dir /usr/local/bin/ + +per fare il backup completo digitare + + allgit2tar forgit.patachina.it Fabio + +per fare il backup di un singolo repository es: Photon + + git2tarAuto forgit.patachina.it Fabio Photon + +per convertire in dir es + + targit2dir Photon + +per convertire tutto in directory per es: + + alltargit2dir + diff --git a/allgit2tar b/allgit2tar new file mode 100755 index 0000000..0cc9652 --- /dev/null +++ b/allgit2tar @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "needed 2 params" + echo "1st param: site without https://" + echo "2nd param: user of git" + echo "i.e.: allgit2tar forgit.patachina.it Fabio" +elif [ $1 == "-h" ]; then + echo "1st param: site without https://" + echo "2nd param: user of git" + echo "i.e.: allgit2tar forgit.patachina.it Fabio" +elif [ -z "$2" ]; then + echo "missing 2nd param: user of git" + echo "the 1st shuold be site without https://" +else + #curl -s https://$1/api/v1/users/$2/repos | jq '.[] | "\(.full_name) \(.default_branch)"' | grep -o '[^"]*' | sed -e "s/^$2\///" | xargs -l git2tar $1 $2 + curl -s https://$1/api/v1/users/$2/repos | jq '.[] | "\(.name) \(.default_branch)"' | grep -o '[^"]*' | xargs -l git2tar $1 $2 +fi diff --git a/alltargit2dir b/alltargit2dir new file mode 100755 index 0000000..7aec6a3 --- /dev/null +++ b/alltargit2dir @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ! -z "$1" ] && [ $1 == "-h" ]; then + echo "1st param optional: dir of output" + echo "i.e.: targit2dir " +elif [ -z "$1" ]; then + echo "1st param optional: dir of output" + echo "i.e.: targit2dir " +elif [ ! -z "$1" ]; then + #echo $1 + ls *.git.tar.gz | xargs -l tar -C $1 -xvzf +else + ls *.git.tar.gz | xargs -l tar -xvzf +fi + diff --git a/git2tar b/git2tar new file mode 100755 index 0000000..0684c08 --- /dev/null +++ b/git2tar @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ ! -z "$1" ] && [ $1 == "-h" ]; then + echo "1st param: site without https://" + echo "2nd param: git user" + echo "3th param: repo name" + echo "4th param: branch" + echo "i.e.: git2tar forgit.patachina.it Fabio wsdd main" +elif [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then + echo "missing parameter, they should be 4" + echo "1st param: site without https://" + echo "2nd param: git user" + echo "3th param: repo name" + echo "4th param: branch" + echo "i.e.: git2tar forgit.patachina.it Fabio wsdd main" +else + #echo "wget -O $3.git.tar.gz https://$1/$2/$3/archive/$4.tar.gz" + wget -O $3.git.tar.gz https://$1/$2/$3/archive/$4.tar.gz +fi diff --git a/git2tarAuto b/git2tarAuto new file mode 100755 index 0000000..9434026 --- /dev/null +++ b/git2tarAuto @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ ! -z "$1" ] && [ $1 == "-h" ]; then + echo "1st param: site without https://" + echo "2nd param: git user" + echo "3st param: repo name" + echo "i.e.: git2tar forgit.patachina.it Fabio wsdd" +elif [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then + echo "missing parameter, they should be 4" + echo "1st param: site without https://" + echo "2nd param: git user" + echo "3st param: repo name" + echo "i.e.: git2tar forgit.patachina.it Fabio wsdd" +else + a=$(curl -s https://$1/api/v1/users/$2/repos | jq '.[] | select(.name=='\"$3\"') | "\(.default_branch)"' | grep -o '[^"]*' ) + wget -O $3.git.tar.gz https://$1/$2/$3/archive/$a.tar.gz +fi diff --git a/targit2dir b/targit2dir new file mode 100755 index 0000000..6a945de --- /dev/null +++ b/targit2dir @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ! -z "$1" ] && [ $1 == "-h" ]; then + echo "1st param: name of name.git.tar.gz " + echo "2nd param optional: dir of output" + echo "i.e.: targit2dir Photon" +elif [ -z "$1" ]; then + echo "1st param: name of name.git.tar.gz " + echo "2nd param optional: dir of output" + echo "i.e.: targit2dir Photon" +elif [ ! -z "$1" ] && [ ! -z "$2" ]; then + tar -xvzf $1.git.tar.gz -C $2 +else + tar -xvzf $1.git.tar.gz +fi