bashbeginner
Bash Timestamped Tar Archive
Safe shell script with exit on error and timestamped gzip archive
By ApeType Staff·13 lines·319 characters·1,420 total attempts
#!/usr/bin/env bash
set -euo pipefail
TARGET_DIR="${1:-./data}"
BACKUP_NAME="backup_$(date +%Y%m%d_%H%M%S).tar.gz"
if [[ ! -d "$TARGET_DIR" ]]; then
echo "Error: Directory $TARGET_DIR does not exist." >&2
exit 1
fi
tar -czf "$BACKUP_NAME" "$TARGET_DIR"
echo "Successfully created: $BACKUP_NAME"
TRANSCRIBE
Ready when you are.
Test your muscle memory and transcription speed against this exact snippet.
Start Typing
Tip: Press Esc anytime to restart
Best runs on this snippet
No recorded runs yet. Be the first to type this snippet!