From e2814cccca2ee9de7432028980adfcc3db1c8f86 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Fri, 11 Feb 2022 18:32:18 -0500 Subject: [PATCH] Fix svn restore issues on Windows --- bin/backup-svn-repo | 6 +++--- bin/restore-svn-backup | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/backup-svn-repo b/bin/backup-svn-repo index e9b11a1..301aa75 100644 --- a/bin/backup-svn-repo +++ b/bin/backup-svn-repo @@ -37,12 +37,12 @@ if [[ $repo_path == "" || $output_path == "" ]]; then exit 1 fi -if [[ ! -d $repo_path ]]; then +if [[ ! -d "$repo_path" ]]; then error "Repo directory '$repo_path' doesn't exist." exit 1 fi -mkdir -p $output_path +mkdir -p "$output_path" now=$(echo $(date '+%Y-%m-%d-%H-%M-%S')) backup_path="$output_path/${now}_jellypixel_repos.dump.gz" @@ -55,4 +55,4 @@ if [[ ! ($proceed == "1" || $proceed == "y") ]]; then exit 1 fi -svnadmin.exe dump $repo_path | gzip -9 > $backup_path +svnadmin.exe dump "$repo_path" | gzip -9 > "$backup_path" diff --git a/bin/restore-svn-backup b/bin/restore-svn-backup index c42d5fa..94578a9 100644 --- a/bin/restore-svn-backup +++ b/bin/restore-svn-backup @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Loads an SVN snapshot into an existing repository. This will replace all existing data in that repo. +# Loads an SVN snapshot into a new repository. # if which tput >/dev/null 2>&1; then @@ -41,22 +41,33 @@ if [[ ($backup_path == "") || ($repo_path == "") ]]; then exit 1 fi -if [[ ! -f $backup_path ]]; then +if [[ ! -f "$backup_path" ]]; then error "Backup file '$backup_path' doesn't exist.\n" exit 1 fi -if [[ ! -d $repo_path ]]; then +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 "The destination repo should be a new repo with no commits.\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 +# Was having trouble getting this to work on svnadmin 1.14.1 on Windows: +# gunzip -c "$backup_path" | svnadmin load "$repo_path" +# It was very slow and the output would freeze. +# So now we unzip and then import. +source_dir=$(dirname "$backup_path") +dump_file="$source_dir/$RANDOM.dump" +printf "${BOLD}Unzipping to '$dump_file'\n" +gunzip -cf "$backup_path" >> "$dump_file" +printf "${BOLD}Loading into SVN repo\n" +svnadmin load -F "$dump_file" "$repo_path" +rm "$dump_file"