BASH 944
Dir Backup By siosios on 1st September 2025 11:25:05 AM
  1. #!/bin/bash
  2. # Backup script for the home directory
  3. TIMESTAMP=$(date '+%Y-%m-%d_%H:%M')
  4. DEST_DIR="$HOME/backups"
  5. SOURCE_DIR="$HOME"
  6. # Create the final backup directory if it doesn't exist
  7. mkdir -p "$DEST_DIR"
  8. # Create a backup directly in the final
  9. tar -czvf "$SOURCE_DIR/home_backup_$TIMESTAMP.tar.gz" -C "$DEST_DIR" .
  10. echo -e "\nBackup of $SOURCE_DIR completed at $DEST_DIR/home_backup_$TIMESTAMP.tar.gz\n"

N/U PasteBin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.