Skip to content

Instantly share code, notes, and snippets.

@greenido
Created August 2, 2023 21:59
Show Gist options
  • Save greenido/e590cb5073573594ba5ee620208a9968 to your computer and use it in GitHub Desktop.
Save greenido/e590cb5073573594ba5ee620208a9968 to your computer and use it in GitHub Desktop.
This bash script will back up all the files in the current directory to a .tar.gz file. 
#!/bin/bash 
# This script will back up all the files in the current directory to a .tar.gz file. 
# Get the current date and time. 
date +"%Y-%m-%d_%H:%M:%S" 
# Create a backup file. 
backup_file="backup_$(date +"%Y-%m-%d_%H:%M:%S").tar.gz" 
# Tar up all of the files in the current directory. 
tar -czvf $backup_file * 
# Print a success message.
echo "Backup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment