Created
October 2, 2017 16:36
-
-
Save ricardodantas/c4e41d928939e69ab9c22fadfa973712 to your computer and use it in GitHub Desktop.
Update all folders which are a valid git repository and create a tar ball (package.tar)
This file contains hidden or 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
| #!/bin/bash | |
| BACKUP_FOLDER=tmp-bkp | |
| echo "=> Creating temp backup folder..." | |
| mkdir -p $BACKUP_FOLDER | |
| for f in *; do | |
| if [[ -d $f ]]; then | |
| echo "=> Updating $f..." | |
| cd $f | |
| if [ -d .git ]; then | |
| git clean -df | |
| git checkout -- . | |
| git checkout master | |
| git pull | |
| echo "=> Creating a package for $f..." | |
| git archive --format zip --output "../$BACKUP_FOLDER/$f.zip" master -0 | |
| fi | |
| cd ../ | |
| fi | |
| done | |
| echo "=> Creating final package..." | |
| tar -cvf package.tar $BACKUP_FOLDER | |
| rm -fr $BACKUP_FOLDER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment