#!/bin/bash # Archives a single directory (given as parameter) to the tar.gz # Date: 2023-04-17 # Check if only one name is given: if [ $# -ne 1 ]; then echo "Only one directory name is allowed!" >&2 exit fi # Check if the name is an actual directory: if [ ! -d $1 ]; then echo "Not a directory: $1!" >&2 exit fi # Create archive name wiht a timestamp: export SOUBOR=`basename "$1"`-`date +%Y-%m-%d`.tgz # Hard work here (it is saved to current directory): echo "Backing $1 to $SOUBOR" >&2 tar czvf $SOUBOR $1 # Control list of then archive file: echo "`ls -l $SOUBOR`" >&2