我有一个脚本,我可以备份整个系统,但我看不出有什么进展。我在进度条脚本中找到了许多答案,但我不知道如何将它们实现到我的备份脚本中。
我的备份脚本:
#!/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"
最佳答案
您可以使用pv为每个文件创建进度条,如下所述:
https://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file