Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSR checklayout and backup expiration #653

Closed
tomglx opened this issue Sep 14, 2015 · 8 comments
Closed

NSR checklayout and backup expiration #653

tomglx opened this issue Sep 14, 2015 · 8 comments
Assignees
Milestone

Comments

@tomglx
Copy link

tomglx commented Sep 14, 2015

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 gdha self-assigned this Sep 14, 2015
@gdha
Copy link
Member

gdha commented Sep 14, 2015

@tomglx Indeed that makes sense. How would you include this test? You are always welcome to prepare a pull request...thx

@tomglx
Copy link
Author

tomglx commented Sep 15, 2015

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
Copy link
Member

gdha commented Sep 19, 2015

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
Copy link
Author

tomglx commented Sep 19, 2015

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
Copy link
Member

gdha commented Sep 21, 2015

@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
Copy link
Author

tomglx commented Sep 21, 2015

@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
Copy link
Member

gdha commented Sep 21, 2015

@tomglx please move your script from layout/save/NSR/default to layout/compare/NSR/default
My mistake!

@tomglx
Copy link
Author

tomglx commented Sep 21, 2015

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants