Skip to content

Instantly share code, notes, and snippets.

@benok
Last active January 24, 2020 12:21
Show Gist options
  • Save benok/68a126227e6779eb3b77612eff9945d0 to your computer and use it in GitHub Desktop.
Save benok/68a126227e6779eb3b77612eff9945d0 to your computer and use it in GitHub Desktop.
Create virtual machine(sparse file) tar.zst archive with progress output and create md5 file
# Usage: chdir to parent directory & set target directory name to D
# (zsh pipe related -> https://stackoverflow.com/a/4995875/26736)
# (md5 creation -> https://serverfault.com/a/120597/70666)
# TODO: convert this one liner to function or shell script with options
tar cvSf - $D 2> >(xargs -I '{}' sh -c "test -f '{}' && md5sum '{}'" |tee $D.md5) | pv -pteb -s $(du -sB1 $D |awk '{print$1}') | nice -10 zstd -15 --sparse -T0 | tee ./$D.tar.zst | md5sum | sed "s/-/$D.tar.zst/" >> $D.md5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment