vcs-backup.sh
branchv_0
changeset 17 fb9b67ba1dae
parent 16 44a8a36ca380
child 18 9353b2531cda
     1.1 --- a/vcs-backup.sh	Mon Apr 22 12:00:35 2019 +0200
     1.2 +++ b/vcs-backup.sh	Tue Apr 23 17:06:58 2019 +0200
     1.3 @@ -86,6 +86,10 @@
     1.4  	echo "$1" | sed -E 's@^[^:]+://@@g';
     1.5  }
     1.6  
     1.7 +# Environment: server
     1.8 +# Lists relative paths (starting wiht hg or git) of all configured repositories
     1.9 +allRepositories() { find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs --no-run-if-empty dirname; }
    1.10 +
    1.11  # Environment: all
    1.12  # $1 = optional value (if missing, reads STDIN)
    1.13  escapeRecfileValue() { if [[ $# = 0 ]]; then awk '{ if (NR > 1) { printf "+ " } print $_ }'; else echo "${@}" | ${FUNCNAME[0]}; fi }
    1.14 @@ -215,7 +219,7 @@
    1.15  	printRecfileKeyValue "%type" "public bool";
    1.16  	echo;
    1.17  
    1.18 -	find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do
    1.19 +	allRepositories | while read d; do
    1.20  		url=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/url.txt");
    1.21  		state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt");
    1.22  		vcsType=$(echo "$d" | sed 's@/.*@@g');
    1.23 @@ -247,7 +251,7 @@
    1.24  	printRecfileKeyValue "%type" "duration int";
    1.25  	printRecfileKeyValue "%type" "resultCode int";
    1.26  
    1.27 -	find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do
    1.28 +	allRepositories | while read d; do
    1.29  		state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt");
    1.30  		vcsType=$(echo "$d" | sed 's@/.*@@g');
    1.31  		absolutePath="$VCS_BACKUP_CURRENT_DIR/$d";
    1.32 @@ -289,7 +293,7 @@
    1.33  	printRecfileKeyValue "%type" "duration int";
    1.34  	printRecfileKeyValue "%type" "resultCode int";
    1.35  	
    1.36 -	find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do
    1.37 +	allRepositories | while read d; do
    1.38  		state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt");
    1.39  		vcsType=$(echo "$d" | sed 's@/.*@@g');
    1.40  		absolutePath="$VCS_BACKUP_CURRENT_DIR/$d";