On Wed, 13 Dec 2023, Tim Herren via BackupPC-users wrote:

> Hi
>
> We noticed the log message about missing pool files appear in the log
> mostly if there was an improper shutdown of the BackupPC Server while a
> backup was in progress.
>
> We developed the following script to get the affected host and backup
> number for each reported missing pool file. The only remedy we found to
> get rid of the error is to delete the affected backups. Please let me
> know if you find any other remedy.
>
> The way it works is that it extracts the hash of the missing pool file,
> subtracts one from the first two letters of the hex value to find the
> correct subfolder in the pool and then correlates that with a backup and
> a host.

Your original version ran successfully for me after some small tweaks for
Debian filesystem layout in 2024, but always left a couple of mystery
files behind.  I finally got sick of them rapidly multiplying in number
and went investigating tonight.

I don't pretend to understand how the pool dir/filename is calculated, but
hex_val_decr needs to be 2 digits, and I had noticed threads elsewhere
that the dir is sometimes AA/BB/AABBCCDD.... and sometimes
AA-[01]/BB-[01]/AABBCCDD...., so I stuck a loop over that.

And a warning to whoever runs this, host=$( ... | cut ... ) and
backup_number=$( ... | cut ... ) are looking at the filename component, so
if your directory layout has your backups under /backuppc instead of
/srv/backuppc, you need to decrement 5 and 6 to 4 and 5.  I'm too lazy to
parameterise that in the below code.

So this version just successfully found my errant backups in /backuppc on
a debian host:





#!/bin/bash

# From 
https://sourceforge.net/p/backuppc/mailman/backuppc-users/thread/2ed5e424-2508-4471-b380-cb8ae93c7d2c%40puzzle.ch/#msg58712645
#
# Script for investigation of missing pool files
#
# To track down sources of log message:
# 2024-03-04 07:51:47  admin : BackupPC_refCountUpdate: missing pool file 
7e97cd4f463f36c175828ca691aed1bd count 1
# https://sourceforge.net/p/backuppc/mailman/message/58712645/
#

LOG_DIR=/var/log/backuppc
BIN_DIR=/usr/share/backuppc/bin
BACKUP_LOCATION=/backuppc

LOG_FILE_NAME="$LOG_DIR/find_missing_pool_files_$(date +%Y%m%d-%H:%M).log"
echo Search for missing pool files started. Logs will be written to 
"$LOG_FILE_NAME"

MISSING_POOL_FILES_HASHES=$(grep 'missing pool' $LOG_DIR/LOG | cut -d' ' -f10)

for full_hex in $MISSING_POOL_FILES_HASHES; do
     hex_val=${full_hex:0:2}
#     hex_val_decr=$(printf "%X" $((0x$hex_val - 1)) | awk '{print 
tolower($0)}')
     for hex_val_decr in 0 1 ; do
         hex_val_decr=$(printf "%02X" $((0x$hex_val - $hex_val_decr)) | awk 
'{print tolower($0)}')

         paths="$BACKUP_LOCATION/pc/*/*/refCnt/poolCnt.1.$hex_val_decr"

         echo "$hex_val - 1 = $hex_val_decr"

         for path in $paths; do
             echo "$path"
             if test -f "$path"; then
                 echo one found
                 pool_cnt_print=$($BIN_DIR/BackupPC_poolCntPrint "$path")
                 # echo "pool_cnt_print=$pool_cnt_print"
                 pool_cnt_match=$(echo "$pool_cnt_print" | grep "$full_hex")

                 if [ -n "$pool_cnt_match" ]; then
                     # echo "pool_cnt_match=$pool_cnt_match, path=$path"
                     #                 host=$(echo "$path" | cut -d'/' -f5)
                     #                 backup_number=$(echo "$path" | cut -d'/' 
-f6)
                     host=$(echo "$path" | cut -d'/' -f4)
                     backup_number=$(echo "$path" | cut -d'/' -f5)
                     echo Found "$full_hex" in Backup Nr. "$backup_number" of 
host "$host" | tee -a "$LOG_FILE_NAME"
                     $BIN_DIR/BackupPC_ls -R -h "$host" -n "$backup_number" -s 
/ / | grep -E "$full_hex"
                 fi
             fi
         done
     done
done



-- 
Tim Connors


_______________________________________________
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    https://github.com/backuppc/backuppc/wiki
Project: https://backuppc.github.io/backuppc/

Reply via email to