lamw / ghettoVCB

ghettoVCB
MIT License
1.27k stars 363 forks source link

Actions to take when backup of VMDKs fails #51

Open riparap opened 9 years ago

riparap commented 9 years ago

It seems that in case backup of VMDK fails for some reason, ghettoVCB continues to backup VM. In this case it will also rotate backups of VM (with checkVMBackupRotation when VM_BACKUP_DIR_NAMING_CONVENTION<>0 => backup directories have date+time in name). I am not sure if this is how it should work by desing or if this is an error.

I think this is anyway somewhat unpleasant situation because it may cause backup to be corrupted so that VM can not be restored from backup...or at least VM will not work properly when some of the disks can not be recovered. If this is not noticed and backups fail in a row multible times, this may cause situation where all stored backups are corrupted.

For this reason I made modifications in my fork of ghettoVCB so that it will terminate backup of VM in case backup of any of its VMDKS's fails. In this case it will delete faulty backup and instead keep old valid backups. This also fixes symlink problem related to failed backup (earlier symlink was not updated, when faulty backup caused backup rotation). To accomplish this I had to change location of compress and rsync blocks and move them in the end of code block for VM backup (original code still exists there but they are commented out).

Does anybody find this approach preferable... ?

Minor errors fixed: In debug mode, free space for SRC_DATASTORE_FREE and DST_DATASTORE_FREE displayed two values because grep command used to filter lines with string "capacity" ('.. | grep -i "capacity" ..') gives two different values in vmw 5.5.0 ("maxVirtualDiskCapacity" and "capacity"). I removed "-i" parameter of grep command to fix this. I do not know how it works with earlier versions of vmware.

Other additions: Added optional variable to supply extra options for VMKFSTOOLS_CMD. Optional variable for extra pause between backup of VMDKs of VM + additional debug messages (to debug cases of failed backup).

lamw commented 5 years ago

Need more feedback before changing the behavior ...