12345678910111213141516171819202122 |
- #!/usr/bin/env bash
- set -euo pipefail # bash strict mode
- display_help(){
- echo "Usage: ${0##*/} [ext] [file/s]"
- exit 2
- }
- [[ $# -lt 2 ]] && display_help
- ext="$1"
- case "$ext" in
- zip) cmd="zip -r9" ;;
- 7z) cmd="7z a -t7z -mx=9" ;;
- tar) cmd="tar -uvf" ;;
- tar.*) cmd="tar -cavf" ;;
- # tar.zst) cmd="tar -c -I'zstd --ultra -filefile -T0' -vf" ;;
- h|\?|:|*) display_help ;;
- esac
- shift 1
- date=$(date +'%F')
- $cmd "archive_${date}_${1}.${ext}" -- "$@"
|