#653 Issue closed
: NSR checklayout and backup expiration¶
Labels: enhancement
, support / question
, fixed / solved / done
tomglx opened issue at 2015-09-14 09:37:¶
rear checklayout detects if the prepared iso image is obsolete. But it
doesn't check if all of the available
NSR backups have expired. So how does one prevent this from happening?
I would prefer that checklayout detects this and so a new mkrescue and
backup would be done.
By the standard cron job. What could be the correct way to integrate
this in the checklayout workflow?
gdha commented at 2015-09-14 11:32:¶
@tomglx Indeed that makes sense. How would you include this test? You are always welcome to prepare a pull request...thx
tomglx commented at 2015-09-15 06:05:¶
Well, I'm proposing two possible solutions.
#1. Implement a media (backup) dependent script template for checking
the availability and consistency of the made ISO backups. This may also
be handy to check if the iso image is still available on remote targets
like http servers or remote rsync directories.
#2. Introduce a new optional parameter for a refresh interval. If the
age of the last created ISO is older than now - refesh interval, then
checklayout should fail. I would then set this equal to the
NSR_RETENTION_TIME. Problem solved. This solution is media independant
and would help to prevent that none of the other checks detect
inconsistent iso content.
Even if I would knew enough about git to prepare a pull request, I also
would have to know enough
about rear code to implement any of these changes.
gdha commented at 2015-09-19 09:53:¶
I guess a script could be created to do this job, e.g. under
layout/save/NSR/default/65_check_iso_retention_time.sh
see (via rear -s checklayout
):
Source layout/save/default/40_check_backup_special_files.sh
Source layout/save/default/45_check_bootloader_files.sh
Source layout/save/default/45_check_network_files.sh
Source layout/save/GNU/Linux/50_extract_vgcfg.sh
Source layout/save/GNU/Linux/51_current_disk_usage.sh
Source layout/save/default/60_snapshot_files.sh
However, the content of the script is for me a bit difficult as I have no mean to test whatsoever.
tomglx commented at 2015-09-19 15:14:¶
Here is a draft for such a script. I'm not sure why the content of the
EXIT_CODE variable is ignored.
Leaving by just executing exit 1 does work, but would that be the
correct way?
NSRSERVER=$(cat $VAR_DIR/recovery/nsr_server )
CLIENTNAME=$(hostname)
nsrinfo -s ${NSRSERVER} -N ${ISO_DIR}/${ISO_PREFIX}.iso ${CLIENTNAME} | \
awk '/objects found/ { if ($1 == 0) exit 1; }'
EXIT_CODE=$?
gdha commented at 2015-09-21 11:39:¶
@tomglx is the output of nsrinfo | awk ...
1 when ISO is missing when
you run it interactively? If the answer is yes, perhaps you could
replace it with:
EXIT_CODE=$( nsrinfo -s ${NSRSERVER} -N ${ISO_DIR}/${ISO_PREFIX}.iso ${CLIENTNAME} | awk '/objects found/ { if ($1 == 0) exit 1; }' )
tomglx commented at 2015-09-21 18:26:¶
@gdha I've included set -xv in the script. Here's the output. Although EXIT_CODE=1, rear -v checklayout finds no difference.
2015-09-21 20:22:36 Including layout/save/NSR/default/65_check_iso_recoverable.sh
NSRSERVER=$(cat $VAR_DIR/recovery/nsr_server )
cat $VAR_DIR/recovery/nsr_server )
cat $VAR_DIR/recovery/nsr_server
+++ cat /var/lib/rear/recovery/nsr_server
++ NSRSERVER=cvk001.cvk.de
CLIENTNAME=$(hostname)
hostname)
hostname
+++ hostname
++ CLIENTNAME=cvk017.cvk.de
nsrinfo -s ${NSRSERVER} -N ${ISO_DIR}/${ISO_PREFIX}.isox ${CLIENTNAME} | \
awk '/objects found/ { if ($1 == 0) exit 1; }'
++ nsrinfo -s cvk001.cvk.de -N /var/lib/rear/output/rear-cvk017.isox cvk017.cvk.de
++ awk '/objects found/ { if ($1 == 0) exit 1; }'
EXIT_CODE=$?
++ EXIT_CODE=1
+ test ''
+ [[ -n '' ]]
+ Log 'Finished running '\''layout/save'\'' stage in 2 seconds'
+ test 1 -gt 0
Stamp)$*"
Stamp)$*
Stamp
++ Stamp
++ date '+%Y-%m-%d %H:%M:%S '
+ echo '2015-09-21 20:22:38 Finished running '\''layout/save'\'' stage in 2 seconds'
2015-09-21 20:22:38 Finished running 'layout/save' stage in 2 seconds
+ SourceStage layout/compare
+ stage=layout/compare
+ shift
+ STARTSTAGE=2
+ Log 'Running '\''layout/compare'\'' stage'
gdha commented at 2015-09-21 18:44:¶
@tomglx please move your script from layout/save/NSR/default to
layout/compare/NSR/default
My mistake!
tomglx commented at 2015-09-21 19:39:¶
@gdha it wasn't the location. My fault. I didn't expected that the
message "Disk layout is identical" wouldn't be printed if my test
fails.
Now I've tested further and adapted my script to make it more verbose.
It works.
NSRSERVER=$(cat $VAR_DIR/recovery/nsr_server )
CLIENTNAME=$(hostname)
OBJECTS=$( nsrinfo -s ${NSRSERVER} -N ${ISO_DIR}/${ISO_PREFIX}.iso ${CLIENTNAME} | \
awk '/objects found/ { print $1; }' )
if [ ${OBJECTS} -eq 0 ]
then
LogPrint "No Networker ISO Backups found."
EXIT_CODE=1
else
LogPrint "${OBJECTS} Networker ISO Backups found."
fi
[Export of Github issue for rear/rear.]