This is the Final part of this section. Here we gonna Create a Real World Backup script which will backup important files and directories.
Backup Script
Create a script that backs up important files and directories to a specified location.
Features:
Takes a source directory and a destination directory as inputs.
Compresses the files into a
.tar.gzarchive.Logs the backup process.
Example:
bash
#!/bin/bash # Backup script echo "Enter the source directory:" read src echo "Enter the destination directory:" read dest timestamp=$(date +"%Y%m%d_%H%M%S") backup_file="$dest/backup_$timestamp.tar.gz" tar -czvf $backup_file $src echo "Backup completed: $backup_file"