4
I'm trying to create a tar of a large LVM volume onto multiple external drives. That part is solved. Now, because it is a LONG process, I'd like a progress bar. From the excellent articles here, I've gotten close.
The issue is that the PV bar quits after the first volume fills up. I'd like PV to continue updating after disks are swapped. Does someone have an idea about how to approach this?
Here's what I've tried. I think the problem is in the last line of code. I'm not sure this strategy will actually work with multi-volumes.
Code ExtBackup.sh:
#!/bin/sh
changedisk()
{
# This routine is called when tar runs out of disk space
# It simply waits for operator to change and mount disks
# then updates the file handle with a new volume number.
echo "Change disks now!"
read -p "Press <enter> when new disk is mounted. ..." NULL
echo ""
# Update the file name with the new volume number
name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
echo ${name:-$TAR_ARCHIVE}-Vol$TAR_VOLUME.tar >&$TAR_FD
}
###########
## MAIN ##
###########
# Test for recursive call to change disks
if [ "$1" = 'changedisk' ]; then
changedisk
exit 0;
fi
# If this is initial call, set SIZE to calculate bytes in source
SIZE=`du -sb *Folder_Name* | cut -f 1`
# Now TAR it, using Multi-volume option and pipe through PV for progress bar
tar -cM -F 'sh ExtBackup.sh changedisk' *Folder_Name* | \
pv -s ${SIZE} > LVMBackup-$(date +%m-%d-%y)-Vol1.tar