diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-07-25 17:20:43 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-07-25 17:20:43 +0200 |
commit | 579993610c0af810051f7ea514dadfa6b616c212 (patch) | |
tree | b264a96b4fa22c8ebe4a7318d649988a9752278b /checkdb | |
parent | fb28c4fe687548541240894332ea75b4c4820167 (diff) | |
download | repo-tools-579993610c0af810051f7ea514dadfa6b616c212.tar.gz repo-tools-579993610c0af810051f7ea514dadfa6b616c212.tar.xz |
Diffstat (limited to 'checkdb')
-rwxr-xr-x | checkdb | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#!/bin/bash + +home="$(dirname "${0}")" +target="${home}/repo" +lock='/tmp/mirrorsync.lck' +tmp="$(mktemp -d)" + +[ -f "${lock}" ] && exit 1 +touch "${lock}" + +trap "rm -rf '${lock}' '${tmp}'" EXIT INT TERM + +find "${target}" -xtype f -name '*.db' | sort > "${tmp}/dbs" +find "${target}" -xtype f -name '*.files' | sed 's/.files/.db/g' | sort > "${tmp}/files" + +if ! diff -q "${tmp}/dbs" "${tmp}/files" >/dev/null; then + echo "there are db or files missing" + diff -u "${tmp}/dbs" "${tmp}/files" + exit 1 +fi + +for db in $(cat "${tmp}/dbs"); do + mkdir "${tmp}/dbdir" "${tmp}/filesdir" + bsdtar xf "${db}" -C "${tmp}/dbdir" + bsdtar xf "${db/.db/.files}" --exclude '*/files' -C "${tmp}/filesdir" + if ! diff -Nrq "${tmp}/dbdir" "${tmp}/filesdir" >/dev/null; then + dbname="${db/${target}\//}" + diff -Nura --label "${dbname}" "${tmp}/dbdir" --label "${dbname/.db/.files}" "${tmp}/filesdir" + echo -e "\n\n" + fi + rm -rf "${tmp}/dbdir" "${tmp}/filesdir" +done |