mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
- yamllint - shfmt config - fix Go bin path - fix git credentials config - add nvm default packages - updated Brewfile
26 lines
494 B
Bash
Executable File
26 lines
494 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
DIRECTORY=$1
|
|
FILENAME=$2
|
|
|
|
if [ -z "${DIRECTORY}" ]; then
|
|
echo "DIRECTORY (first argument) is missing"
|
|
echo "Usage: $0 folder_to_backup"
|
|
exit
|
|
fi
|
|
|
|
if [ -z "${FILENAME}" ]; then
|
|
FILENAME=$DIRECTORY
|
|
fi
|
|
|
|
FILENAME=${FILENAME} \
|
|
| tr '/' _ \
|
|
| iconv -t ascii//TRANSLIT \
|
|
| sed -r s/[^a-zA-Z0-9]+/_/g \
|
|
| sed -r s/^_+\|-+$//g
|
|
|
|
TIMESTAMP=$(date "+%Y%m%d_%H%M%S")
|
|
FILENAME_TIMESTAMP="${FILENAME}_${TIMESTAMP}"
|
|
|
|
tar cvzf "${FILENAME_TIMESTAMP}.tar.gz" "${DIRECTORY}/"
|