Skip to content

Instantly share code, notes, and snippets.

@gadiener
Forked from kopiro/backup-repos.sh
Created October 15, 2018 10:16
Show Gist options
  • Save gadiener/34b36ca45d0eb1470dcab356ff9cc9c0 to your computer and use it in GitHub Desktop.
Save gadiener/34b36ca45d0eb1470dcab356ff9cc9c0 to your computer and use it in GitHub Desktop.
Backup all Repositories in current directory
#!/bin/bash
for i in $(find . -type d -maxdepth 1 -mindepth 1); do
echo "Backup $i..."
zip_name="$i-$(date +'%y%m%d').zip"
pushd "$i" && \
git archive --format=zip --output="/opt/backups/$zip_name" master && \
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment