我有一个脚本,可以对整个系统进行备份,但是看不到进度如何。我发现进度条脚本有很多答案,但是我不知道如何在备份脚本中实现它们。
我的备份脚本:
#!/bin/bash
Backup_system="Backup_$(date +%Y-%m-%d).tar.gz"
# Record start time by epoch second
start=$(date '+%s')
# List of excludes in a bash array, for easier reading.
excludes=(--exclude=/$Backup_system)
excludes+=(--exclude=/proc)
excludes+=(--exclude=/lost+found)
excludes+=(--exclude=/sys)
excludes+=(--exclude=/mnt)
excludes+=(--exclude=/media)
excludes+=(--exclude=/dev)
if ! tar -czf "$Backup_system" "${excludes[@]}" /; then
status="tar failed"
elif ! mv "$Backup_system" ~/Backups ; then
status="mv failed"
else
status="success: size=$(stat -c%s ~/Backups/$Backup_system) duration=$((`date '+%s'` - $start))"
fi
# Log to system log; handle this using syslog(8).
logger -t Backup_system "$status"
答案 0 :(得分:0)
您可以使用pv为每个文件创建一个进度条,如下所示: https://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file