PHPackages                             samhernandez/craft-db-paths - 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. [Database &amp; ORM](/categories/database)
4. /
5. samhernandez/craft-db-paths

ActiveCraft-module[Database &amp; ORM](/categories/database)

samhernandez/craft-db-paths
===========================

Fix failed Craft backups and restores with full paths to psql, mysql, and mysqldump executables.

1.0.2(6y ago)2965[1 issues](https://github.com/samhernandez/craft-db-paths/issues)MITPHPCI failing

Since Dec 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/samhernandez/craft-db-paths)[ Packagist](https://packagist.org/packages/samhernandez/craft-db-paths)[ RSS](/packages/samhernandez-craft-db-paths/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (1)Versions (3)Used By (0)

Craft DB Paths Module
=====================

[](#craft-db-paths-module)

Skip to [the usage instructions](##usage) if you already know the story.

Background
----------

[](#background)

Craft relies by default on the `mysqldump` and `mysql` executables to backup and restore databases. The default backup command looks like this:

```
mysqldump […options…] {database} > {file}'

```

The problem is that, while `mysqldump` might be available in the system, PHP running under a web request doesn’t know where to find it because it’s not in any directories specified in the `PATH` environmental variable. This is true when running locally with MAMP. It’s also true sometimes on EC2 instances when running MariaDB on RDS.

For this reason, Craft provides two configuration variables for you: [`backupCommand`](https://docs.craftcms.com/v3/config/config-settings.html#backupcommand) and [`restoreCommand`](https://docs.craftcms.com/v3/config/config-settings.html#restorecommand). You can write your own command with the full path to the `mysqldump` executable. For MAMP it might be something like this:

```
/Applications/MAMP/Library/bin/mysqldump […options…] {database} > {file}

```

The thing is, Craft’s default dump command is really nice. It excludes unnecessary session, cache, and asset data. You can see how it’s built for MySQL in the [Schema::defaultBackupCommand()](https://github.com/craftcms/cms/blob/master/src/db/mysql/Schema.php#L146-L190) method. What if you could just replace `mysqldump` with its full path and not have to roll your own command? That's what this module is for.

Usage
-----

[](#usage)

### Installation

[](#installation)

This is a module for Craft CMS, not a plugin available in Craft's Plugin Store. It is installed with composer on the command line.

Run the following command in the root of your project.

```
composer require samhernandez/craft-db-paths
```

Open `/config/app.php`, add the `CraftDbPaths` class as a module, and bootstrap it. Example:

```
return [
    'modules' => [
        'craft-db-paths' => \samhernandez\craftdbpaths\CraftDbPaths::class,
    ],
    'bootstrap' => ['craft-db-paths'],
];
```

### Configuration

[](#configuration)

Add any of the following env vars to your `.env` file. Here is an example for MAMP on a Mac with MySQL.

```
PATH_TO_MYSQL=/Applications/MAMP/Library/bin/mysql
PATH_TO_MYSQLDUMP=/Applications/MAMP/Library/bin/mysqldump

```

If necessary, you can add paths for Postgres too.

```
PATH_TO_PSQL=/usr/local/bin/psql
PATH_TO_PGDUMP=/usr/local/bin/pg_dump

```

No configuration file is necesary, just env variables set in your `.env` or otherwise.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~403 days

Total

2

Last Release

2367d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/123042?v=4)[Sam Hernandez](/maintainers/samhernandez)[@samhernandez](https://github.com/samhernandez)

---

Top Contributors

[![samhernandez](https://avatars.githubusercontent.com/u/123042?v=4)](https://github.com/samhernandez "samhernandez (3 commits)")

---

Tags

backupmysqlmysqldumpCraftpsql

### Embed Badge

![Health badge](/badges/samhernandez-craft-db-paths/health.svg)

```
[![Health](https://phpackages.com/badges/samhernandez-craft-db-paths/health.svg)](https://phpackages.com/packages/samhernandez-craft-db-paths)
```

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k6.0M77](/packages/ifsnop-mysqldump-php)[phpbu/phpbu

PHP Backup utility.

1.3k95.3k4](/packages/phpbu-phpbu)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

62414.3k11](/packages/rah-danpu)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1474.7k1](/packages/cytopia-mysqldump-secure)[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k70](/packages/verbb-formie)[druidfi/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

35612.8k7](/packages/druidfi-mysqldump-php)

PHPackages © 2026

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