11 lines285 B

#!/bin/sh
# Back up a folder with today's date in the name
src="$HOME/notes"
dest="$HOME/backups/notes-$(date +%F).tar.gz"
if [ ! -d "$src" ]; then
echo "Nothing to back up: $src is missing" >&2
exit 1
fi
mkdir -p "$HOME/backups"
tar -czf "$dest" "$src" && echo "Saved $dest"