Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Last active August 29, 2015 14:16
Show Gist options
  • Save michaeltwofish/fb778f93173d9ec86710 to your computer and use it in GitHub Desktop.
Save michaeltwofish/fb778f93173d9ec86710 to your computer and use it in GitHub Desktop.
#!/bin/sh
#/ Usage: ghe-export-pages | ssh admin@enterprise -- ghe-import-pages
set -e
# Show usage.
if [ "$1" = "--help" ]
then grep '^#/' <"$0" |cut -c 4-
exit 2
fi
[ "`whoami`" = "git" ] || {
exec sudo -u git "$0" "$@"
echo Run this script as the git user. >&2
exit 1
}
if [ -d "/data/pages" ]; then
tar -cf - -C /data pages
else
echo No pages data exists to export. >&2
exit 1
fi
#!/bin/bash
#/ Usage: ghe-export-repositories | ssh admin@enterprise -- ghe-import-repositories
#/
#/ This utility exports a backup, which can be imported with ghe-import-repositories.
#/
#/ OPTIONS:
#/ -h Show this message
set -e
usage() {
grep '^#/' <"$0" | cut -c 4-
}
[ "`whoami`" = "git" ] || {
exec sudo -u git "$0" "$@"
echo Run this script as the git user. >&2
exit 1
}
while getopts "h" OPTION; do
case $OPTION in
h)
usage
exit 2
;;
?)
usage
exit
;;
esac
done
# Pack refs so that we don't risk resurrecting deleted refs on import, since we
# pack refs when we import.
find /data/repositories/ -maxdepth 1 -name \*.git -type d -exec git -C {} pack-refs --all \;
tar \
--exclude=__nodeload_archives__ \
--exclude=__gitmon__ \
-cf - \
-C /data \
repositories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment