Skip to content

Commit

Permalink
chore(gh-backup): edit example script
Browse files Browse the repository at this point in the history
Now it should delete all empty folders. In case of error (non-existent repository or DMCA'd), old copies will not be deleted.
  • Loading branch information
n0bodysec committed Mar 6, 2022
1 parent 878ef19 commit e3482cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gh-backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ TIMESTAMP=$(date +%s)
USERNAME=n0bodysec
MAX_BACKUPS=2

# exit immediately if a command exits with a non-zero status.
# set -e

# backup repositories
github-backup $USERNAME --token=$GH_TOKEN --all --fork --output-directory=$WORK_DIR/data/$USERNAME/$TIMESTAMP

# delete empty folders
find $WORK_DIR/data/$USERNAME/ -type d -empty -maxdepth 1 | xargs rm -rf

# delete old backups
ls -d1 $WORK_DIR/data/$USERNAME/* | head -n -${MAX_BACKUPS} | xargs rm -rf

Expand Down

0 comments on commit e3482cd

Please sign in to comment.