PHPackages                             autobackup/script - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. autobackup/script

ActiveProject

autobackup/script
=================

Standalone Automatic MySQL database backup sent directly to your email

00PHP

Since Jul 23Pushed todayCompare

[ Source](https://github.com/mohamed-sinani/autobackup-script)[ Packagist](https://packagist.org/packages/autobackup/script)[ RSS](/packages/autobackup-script/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

AutoBackup Script For your App
==============================

[](#autobackup-script-for-your-app)

Automatic MySQL/MariaDB backup sent to your email. Works with any app that uses MySQL/MariaDB — PHP, Python, Node.js, Java, Ruby, or anything else.

Requirements
------------

[](#requirements)

- PHP 7.4+
- `pdo` and `pdo_mysql` extensions
- Composer
- MySQL or MariaDB
- SMTP server (Gmail, Mailgun, SendGrid, etc.)

---

For Linux Servers
-----------------

[](#for-linux-servers)

### 1. Install

[](#1-install)

**Option A - Composer:**

```
cd ~/Downloads
composer create-project autobackup/script
```

**Option B - Git:**

```
cd ~/Downloads
git clone https://github.com/mohamed-sinani/autobackup-script.git
cd autobackup-script
composer install
```

### 2. Configure

[](#2-configure)

```
cp .env.example .env
nano .env
```

Fill in your details:

```
# ── Database Settings ─────────────────────────────────────────
DB_HOST=localhost
DB_PORT=3306
DB_NAME=your_database_name      # Name of the database to back up
DB_USER=root                    # Database username
DB_PASS=your_password           # Database password

# ── Email Settings (SMTP) ────────────────────────────────────
# Leave SEND_EMAIL=false to skip email (local backup only)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=you@gmail.com     # Your Gmail / SMTP username
SMTP_PASSWORD=your_app_password # App password (see Gmail Setup below)
SMTP_ENCRYPTION=tls
FROM_EMAIL=you@gmail.com
FROM_NAME=AutoBackup

# ── Backup Settings ──────────────────────────────────────────
BACKUP_DIR=backups              # Folder to store backups
RECIPIENT_EMAIL=you@gmail.com   # Where to send the backup
KEEP_DAYS=7                     # Delete backups older than this

# ── Options ──────────────────────────────────────────────────
SEND_EMAIL=true                 # Set to "false" for backup only, no email

```

### 3. Test

[](#3-test)

```
php backup.php
```

### 4. Auto Schedule (cron)

[](#4-auto-schedule-cron)

Open crontab:

```
crontab -e
```

> **First time?** You'll see a prompt to choose an editor. Just type `1` and press Enter to select nano (the easiest option).

Add this line:

```
0 3 * * * /usr/bin/php ~/Downloads/autobackup-script/backup.php >> ~/Downloads/autobackup-script/backup.log 2>&1

```

**What this does:** Runs backup every day at 3:00 AM.

---

For Windows Servers
-------------------

[](#for-windows-servers)

### 1. Install

[](#1-install-1)

**Option A - Composer:**

```
cd %USERPROFILE%\Downloads
composer create-project autobackup/script
```

**Option B - Git:**

```
cd %USERPROFILE%\Downloads
git clone https://github.com/mohamed-sinani/autobackup-script.git
cd autobackup-script
composer install
```

### 2. Configure

[](#2-configure-1)

```
copy .env.example .env
notepad .env
```

Fill in your details:

```
# ── Database Settings ─────────────────────────────────────────
DB_HOST=localhost
DB_PORT=3306
DB_NAME=your_database_name      # Name of the database to back up
DB_USER=root                    # Database username
DB_PASS=your_password           # Database password

# ── Email Settings (SMTP) ────────────────────────────────────
# Leave SEND_EMAIL=false to skip email (local backup only)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=you@gmail.com     # Your Gmail / SMTP username
SMTP_PASSWORD=your_app_password # App password (see Gmail Setup below)
SMTP_ENCRYPTION=tls
FROM_EMAIL=you@gmail.com
FROM_NAME=AutoBackup

# ── Backup Settings ──────────────────────────────────────────
BACKUP_DIR=backups              # Folder to store backups
RECIPIENT_EMAIL=you@gmail.com   # Where to send the backup
KEEP_DAYS=7                     # Delete backups older than this

# ── Options ──────────────────────────────────────────────────
SEND_EMAIL=true                 # Set to "false" for backup only, no email

```

### 3. Test

[](#3-test-1)

```
php backup.php
```

### 4. Auto Schedule (Task Scheduler)

[](#4-auto-schedule-task-scheduler)

1. Open **Task Scheduler** (search in Start menu)
2. Click **Create Basic Task**
3. Name: `AutoBackup`
4. Trigger: **Daily** → set time to `3:00 AM`
5. Action: **Start a program**
    - Program: `C:\php\php.exe` (your PHP path)
    - Arguments: `%USERPROFILE%\Downloads\autobackup-script\backup.php`
6. Click **Finish**

---

Commands
--------

[](#commands)

CommandWhat it does`php backup.php`Backup + send email`php backup.php --dry-run`Backup only, skip email`php backup.php --no-email`Same as dry-run---

Gmail Setup
-----------

[](#gmail-setup)

Gmail needs an [App Password](https://myaccount.google.com/apppasswords), not your regular password:

1. Go to [Google Account](https://myaccount.google.com) → Security
2. Enable **2-Step Verification** (required)
3. Go to **App Passwords**
4. Generate one for **Mail**
5. Use that password in `.env`

---

SMTP Providers
--------------

[](#smtp-providers)

ProviderHostPortGmailsmtp.gmail.com587Outlooksmtp.office365.com587Mailgunsmtp.mailgun.org587SendGridsmtp.sendgrid.net587Amazon SESemail-smtp.us-east-1.amazonaws.com587---

Troubleshooting
---------------

[](#troubleshooting)

ErrorFix`vendor/autoload.php not found`Run `composer install``Database connection failed`Check `DB_*` values in `.env``Email sending failed`Verify SMTP credentials, check port 587---

License
-------

[](#license)

MIT - Mohamed Sinani

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/149929000?v=4)[Mohamed Sinani](/maintainers/mohamed-sinani)[@mohamed-sinani](https://github.com/mohamed-sinani)

---

Top Contributors

[![mohamed-sinani](https://avatars.githubusercontent.com/u/149929000?v=4)](https://github.com/mohamed-sinani "mohamed-sinani (10 commits)")

### Embed Badge

![Health badge](/badges/autobackup-script/health.svg)

```
[![Health](https://phpackages.com/badges/autobackup-script/health.svg)](https://phpackages.com/packages/autobackup-script)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
