I've been using this one line command that I found on another post here and it works great for one folder at a time. This is the command:
tar -cf - /opt/folder1 | pv -s $(du -sb /opt/folder1 | awk '{print $1}') | gzip > archive.tar.gz
How can that be changed to work for multiple files/folders at a time and get the overall progress, rather than running the same command for each folder/file. Here is the use case:
I have /opt/folder1, /opt/folder2 and /opt/folder3/*.db files. These can all be combined like into one variable like this.
filestobackup=(
/opt/folder1
/opt/folder2
/opt/folder3/*.db
)
This does not work:
tar -cf - "${filestobackup[@]}" | pv -s $(du -sb "${filestobackup[@]}" | awk '{print $1}') | gzip > archive.tar.gz