This Bash script automates the process of securely backing up critical directories, encrypting the archive, and distributing it to multiple destinations with retention and cleanup policies.
- Backup Sources:
/var/www
,/etc/caddy
,/var/log/caddy
,/var/log/
- Destinations:
/mnt/nfs/primary
,/mnt/nfs/secondary
- Encryption: AES-128-CBC with PBKDF2 and SHA-3-256 hashed key
- Retention Policy: Deletes backups older than 60 days
- Logging: Logs success/failure of backup transfers
- Safety Checks: Verifies disk space before copying
- Cleanup: Removes temporary files after completion
- Setup: Creates and secures necessary directories
- Compression: Archives source directories into a
.tar.gz
file - Encryption: Encrypts the archive using OpenSSL
- Disk Check: Ensures enough space is available at destinations
- Copy: Transfers encrypted backup to all destinations
- Cleanup: Deletes temporary files
- Retention: Removes old backups based on defined policy
- Uses a hashed encryption key stored securely in
/etc/backups/encryption_key.txt
- Encrypted backups are stored with
.tar.gz.enc
extension
This Bash script automates the secure restoration of encrypted backup archives. It provides an interactive, user-friendly interface with color-coded prompts and safety checks.
- 🔐 Decryption using AES-128-CBC with PBKDF2 and SHA3-256 hashed keys
- 📁 Interactive selection of backup server and archive
- 🛡️ Safety checks for protected directories and permissions
- 🧵 Parallel decryption and extraction for efficiency
- 🧹 Automatic cleanup of temporary files on exit
- Select Backup Server: Choose between predefined backup sources (e.g., Primary or Secondary Server).
- List & Select Archive: Displays available
.tar.gz.enc
files for restoration. - Destination Directory: Prompts for a safe extraction path with overwrite confirmation.
- Decrypt & Extract: Decrypts and extracts each archive in parallel to the specified location.
- OpenSSL
- Access to the encryption key at
/etc/backups/encryption_key.txt
- Sufficient permissions for reading backups and writing to the destination