diff -r 5454e8a0c53e -r d46ed3f5c72b vcs-backup.sh --- a/vcs-backup.sh Sat Apr 20 22:24:24 2019 +0200 +++ b/vcs-backup.sh Sun Apr 21 00:05:19 2019 +0200 @@ -205,11 +205,47 @@ # User: $VCS_BACKUP_USER # should be called from cron (usually every day) vcs_backup_public_serverPullCronTask() { - return; + echo "%rec: pull"; + echo "%type: started date"; + echo "%type: finished date"; + echo "%type: duration int"; + echo "%type: resultCode int"; + + find "$VCS_BACKUP_CONFIG_DIR" -name url.txt -printf '%P\n' | sort | xargs dirname | 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"; + + + pullStarted=$(date --iso-8601=s); + pullStartedMiliseconds=$(($(date +%s%N)/1000000)); + pullFinished=""; + pullDuration=""; + pullResult=""; + pullResultCode=""; + if [[ "$state" == "cloned" ]]; then + if [[ "$vcsType" == "hg" ]]; then pullResult=$(hg pull --force --repository "$absolutePath" 2>&1); pullResultCode=$?; + elif [[ "$vcsType" == "git" ]]; then pullResult=$(git -C "$absolutePath" fetch 2>&1); pullResultCode=$?; + fi + pullFinished=$(date --iso-8601=s); + pullFinishedMiliseconds=$(($(date +%s%N)/1000000)); + pullDuration=$(( $pullFinishedMiliseconds - $pullStartedMiliseconds )); + fi + + printRecfileKeyValue "serverPath" "$absolutePath"; + printRecfileKeyValue "type" "$vcsType"; + printRecfileKeyValue "state" "$state"; + printRecfileKeyValue "started" "$pullStarted"; + printRecfileKeyValue "finished" "$pullFinished"; + printRecfileKeyValue "duration" "$pullDuration"; + printRecfileKeyValue "resultCode" "$pullResultCode"; + printRecfileKeyValue "message" "$pullResult"; + echo; + done } # Environment: server -# User: $VCS_BACKUP_USER +# User: root # should be called from cron (usually every day) after Pull (see above) vcs_backup_public_serverSnapshotCronTask() { return;