diff -r 44a8a36ca380 -r fb9b67ba1dae vcs-backup.sh --- a/vcs-backup.sh Mon Apr 22 12:00:35 2019 +0200 +++ b/vcs-backup.sh Tue Apr 23 17:06:58 2019 +0200 @@ -86,6 +86,10 @@ echo "$1" | sed -E 's@^[^:]+://@@g'; } +# Environment: server +# Lists relative paths (starting wiht hg or git) of all configured repositories +allRepositories() { find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs --no-run-if-empty dirname; } + # Environment: all # $1 = optional value (if missing, reads STDIN) escapeRecfileValue() { if [[ $# = 0 ]]; then awk '{ if (NR > 1) { printf "+ " } print $_ }'; else echo "${@}" | ${FUNCNAME[0]}; fi } @@ -215,7 +219,7 @@ printRecfileKeyValue "%type" "public bool"; echo; - find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do + allRepositories | while read d; do url=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/url.txt"); state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt"); vcsType=$(echo "$d" | sed 's@/.*@@g'); @@ -247,7 +251,7 @@ printRecfileKeyValue "%type" "duration int"; printRecfileKeyValue "%type" "resultCode int"; - find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do + allRepositories | while read d; do state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt"); vcsType=$(echo "$d" | sed 's@/.*@@g'); absolutePath="$VCS_BACKUP_CURRENT_DIR/$d"; @@ -289,7 +293,7 @@ printRecfileKeyValue "%type" "duration int"; printRecfileKeyValue "%type" "resultCode int"; - find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | while read d; do + allRepositories | while read d; do state=$(cat "$VCS_BACKUP_CONFIG_DIR/$d/state.txt"); vcsType=$(echo "$d" | sed 's@/.*@@g'); absolutePath="$VCS_BACKUP_CURRENT_DIR/$d";