Add some scripts

This commit is contained in:
2022-02-11 16:47:18 -05:00
parent cbc753a6bf
commit 8990eb866d
7 changed files with 262 additions and 1 deletions

62
bin/restore-svn-backup Normal file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
#
# Loads an SVN snapshot into an existing repository. This will replace all existing data in that repo.
#
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
fi
error() {
printf "${BOLD}${RED}$1${NORMAL}\n"
}
set -e
backup_path="$1"
repo_path="$2"
if [[ ($backup_path == "") || ($repo_path == "") ]]; then
error "Missing args: <backup file path> <svn repo path>"
exit 1
fi
if [[ ! -f $backup_path ]]; then
error "Backup file '$backup_path' doesn't exist.\n"
exit 1
fi
if [[ ! -d $repo_path ]]; then
error "SVN repo '$repo_path' doesn't exist.\n"
exit 1
fi
printf "${BOLD}${YELLOW}Loading backup '$backup_path' to '$repo_path'\n"
printf "This will replace all existing data in the repo.\n"
printf "Proceed? (1|y)\n> ${NORMAL}"
read -e proceed
if [[ ! ($proceed == "1" || $proceed == "y") ]]; then
exit 1
fi
gunzip -c $backup_path | svnadmin load $repo_path