我正在尝试将大型 LVM 卷的 tar 创建到多个外部驱动器上。那部分已经解决了。现在,因为这是一个漫长的过程,我想要一个进度条。从这里的优秀文章中,我已经接近了。
问题是PV条在第一个卷填满后退出。我希望 PV 在磁盘交换后继续更新。有人知道如何解决这个问题吗?
这是我尝试过的。
代码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
答案1
也许-f -
之前尝试-F
强制 tar 将其所有输出数据发送到 stdout ?