Last active
June 30, 2016 17:22
-
-
Save mschuwalow/8c5d24d82233c146c53131e36e394196 to your computer and use it in GitHub Desktop.
Revisions
-
mschuwalow revised this gist
Jun 30, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ set BACKUP_DIR /home/pi/backup/gitlab set TOKEN set PRUNE_AFTER 3 set TSTAMP (date "+%Y%m%d-%H%M") -
mschuwalow revised this gist
Jun 30, 2016 . 1 changed file with 14 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,36 @@ set BACKUP_DIR /home/pi/backup/gitlab set TOKEN xR2_71SwD-xnj4mkoyeL set PRUNE_AFTER 3 set TSTAMP (date "+%Y%m%d-%H%M") set API https://gitlab.com/api/v3/projects/ function tgz echo $argv tar -zcf {$argv}.tar.gz $argv rm -rf $argv end echo "=== INITIALIZING ===" echo "Using backup directory $BACKUP_DIR" mkdir -p $BACKUP_DIR set REPOLIST (curl -H "PRIVATE-TOKEN: $TOKEN" https://gitlab.com/api/v3/projects/ | awk -v "ORS=," '{print}'| sed 's/,/\n/g' | grep "http_url_to_repo" | sed "s/\"http_url_to_repo\"://" | sed "s/https/http/" | sed 's/"//' | sed 's/"//') for REPO in $REPOLIST echo "Backing up $REPO" set TEMP (echo $REPO | sed "s/http:.*\///" | sed "s/.git//") git clone $REPO {$BACKUP_DIR}/{$TEMP}-{$TSTAMP} tgz {$BACKUP_DIR}/{$TEMP}-{$TSTAMP} end echo "=== PRUNING ===" echo "Pruning backup files $PRUNE_AFTER days old or older." echo Found (find $BACKUP_DIR -name '*.tar.gz' -mtime +{$PRUNE_AFTER} | wc -l) files to prune. rm -rf (find $BACKUP_DIR -name '*.tar.gz' -mtime +{$PRUNE_AFTER}) echo "=== DONE ===" -
mschuwalow revised this gist
Jun 30, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ echo "=== INITIALIZING ===" echo "Using backup directory $BACKUP_DIR" mkdir -p $BACKUP_DIR set REPOLIST (curl -H "PRIVATE-TOKEN: $TOKEN" https://gitlab.com/api/v3/projects/ | awk -v "ORS=," '{print}'| sed 's/,/\n/g' | grep "http_url_to_repo" | sed "s/\"http_url_to_repo\"://" | sed "s/https/http/") for REPO in $REPOLIST echo "Backing up $REPO" -
mschuwalow revised this gist
Jun 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ set BACKUP_DIR set TOKEN set PRUNE_AFTER 3 -
mschuwalow created this gist
Jun 22, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ set BACKUP_DIR /home/maxim/temp/testssd set TOKEN set PRUNE_AFTER 3 set TSTAMP (date "+%Y%m%d-%H%M") set API https://gitlab.com/api/v3/projects/ echo "=== INITIALIZING ===" echo "Using backup directory $BACKUP_DIR" mkdir -p $BACKUP_DIR set REPOLIST (curl -H "PRIVATE-TOKEN: $TOKEN" $API | awk -v "ORS=," '{print}'| sed 's/,/\n/g' | grep "http_url_to_repo" | sed "s/\"http_url_to_repo\"://" | sed "s/\"//" | sed "s/\"//") for REPO in $REPOLIST echo "Backing up $REPO" set TEMP (echo $REPO | sed "s/https:.*\///" | sed "s/.git//") git clone --quiet --mirror $REPO {$BACKUP_DIR}/{$TEMP}-{$TSTAMP} tgz {$GHBU_BACKUP_DIR}/{$TEMP}-{$TSTAMP} end echo "=== PRUNING ===" echo "Pruning backup files $PRUNE_AFTER days old or older." echo "Found `find $BACKUP_DIR -name '*.tar.gz' -mtime +$PRUNE_AFTER | wc -l` files to prune." find $BACKUP_DIR -name -mtime +$PRUNE_AFTER -exec rm -fv {} > /dev/null echo "=== DONE ===" echo "GitHub backup completed."