Simple Backup Tool - User Guide

This guide explains how to use the Simple Backup Tool, a bash script that helps you back up web directories and MySQL databases with optional descriptions.

📥 Installation

  1. nano backup\_tool. Paste the script content and save (Ctrl+O, Enter, Ctrl+X).

  2. chmod +x backup\_tool.sh

  3. ./backup\_tool.sh

🔄 How It Works

1️⃣ Web Directory Backup

  • Input:

    • Source Directory: Path to the folder you want to back up.

    • Destination Directory: Where the backup will be saved.

    • Filename: Default includes timestamp (e.g., web_backup_20240125_142022.tar.gz).

    • Description (Optional): Add notes about the backup.

  • Output:

    • A compressed .tar.gz backup file.

    • A README_*.txt file with details (if description was added).

2️⃣ MySQL Database Backup

  • Input:

    • MySQL Credentials: Username, password, and host (default: localhost).

    • Select Databases: Choose which databases to back up.

    • Filename: Default includes database name and timestamp (e.g., db_backup_mydb_20240125_142022.sql.gz).

    • Description (Optional): Add notes about the backup.

  • Output:

    • A compressed .sql.gz file for each database.

    • A README_*.txt file for each backup (if description was added).

📜 Example Usage

Backing Up a Web Directory

  1. ./backup\_tool.sh

  2. Choose "Backup web directory?" (y).

  3. Enter:

    • Source Directory: /var/www/mywebsite

    • Destination Directory: ~/backups

    • Filename: (Press Enter for default or type a custom name)

    • Description: (Optional) "Main website backup before updates"

✅ Output:

  • ~/backups/web_backup_20240125_142022.tar.gz

  • ~/backups/README_web_backup_20240125_142022.txt

Backing Up MySQL Databases

  1. ./backup\_tool.sh

  2. Choose "Backup MySQL databases?" (y).

  3. Enter:

    • MySQL Username: root

    • MySQL Password: (hidden input)

    • MySQL Host: (Press Enter for localhost)

    • Select Databases: Choose from the list (e.g., mydb).

    • Filename: (Press Enter for default or type a custom name)

    • Description: (Optional) "Production DB backup before migration"

✅ Output:

  • ~/backups/db_backup_mydb_20240125_142022.sql.gz

  • ~/backups/README_db_backup_mydb_20240125_142022.txt

🔍 Viewing Backup Details

Each backup generates a README file with:

  • Date & Time

  • Backup Name & Location

  • Size

  • Description (if provided)

Example README_*.txt:

Backup Information ================= Date: Fri Jan 25 14:20:22 UTC 2024 Backup Name: web_backup_20240125_142022.tar.gz Location: /home/user/backups Size: 245M Description: Main website backup before updates

🛑 Troubleshooting

** "Directory doesn't exist!" **Check the path and try again. **"No databases found!" **verify MySQL credentials and permissions. Backup failsEnsure enough disk space in the destination. **Script permission denied **Run chmod +x backup\_tool.sh.

📌 Tips

✔ Store backups securely (cloud/external drive).✔ Test restoring backups to ensure they work.✔ Use descriptions to remember why each backup was made.

🚀 Ready to Use?

Run the script and start backing up!

./backup_tool.sh