Created
June 7, 2018 12:19
-
-
Save Soben/51fc223c94476f496b3a81f2ae4b30a1 to your computer and use it in GitHub Desktop.
Quick Git Backup and Zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bsbb { | |
currentDate=`date +"%Y%m%d"` | |
if [ "$1" ]; then | |
printf "${COLOR_YELLOW}Getting repository${COLOR_DEFAULT}\n" | |
git clone "git@TEAMNAME.git.beanstalkapp.com:/TEAMNAME/$1.git" || return 1 | |
printf "${COLOR_YELLOW}Zipping up folder${COLOR_DEFAULT}\n" | |
zip -qr "$1-$currentDate.zip" "$1/" | |
if [ $? -eq 1 ]; then | |
rm -rf ./* | |
printf "${COLOR_RED}Zip failed!\n" | |
return 1 | |
fi | |
printf "${COLOR_YELLOW}Removing temporary folder${COLOR_DEFAULT}\n" | |
rm -rf "$1" | |
if [ $? -eq 1 ]; then | |
printf "${COLOR_RED}Could not delete folder${COLOR_DEFAULT}\n" | |
return 1 | |
fi | |
printf "\n${COLOR_GREEN}Backed Up Successfully${COLOR_DEFAULT}\n" | |
return 0 | |
fi | |
printf "${COLOR_RED}You must specify a repo!${COLOR_DEFAULT}\n" | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment