PHPackages                             cleaniquecoders/laravel-config-backup - 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. [Security](/categories/security)
4. /
5. cleaniquecoders/laravel-config-backup

ActiveLibrary[Security](/categories/security)

cleaniquecoders/laravel-config-backup
=====================================

Backup and restore Laravel configuration (.env and database settings) as a portable AES-256 encrypted archive.

v1.0.0(yesterday)00MITPHPPHP ^8.3||^8.4CI passing

Since Jun 8Pushed yesterdayCompare

[ Source](https://github.com/cleaniquecoders/laravel-config-backup)[ Packagist](https://packagist.org/packages/cleaniquecoders/laravel-config-backup)[ Docs](https://github.com/cleaniquecoders/laravel-config-backup)[ GitHub Sponsors]()[ RSS](/packages/cleaniquecoders-laravel-config-backup/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (16)Versions (2)Used By (0)

Laravel Config Backup
=====================

[](#laravel-config-backup)

[![Latest Version on Packagist](https://camo.githubusercontent.com/16025395aec87a1c43576fc23ca6fa7cd3ad0c18b34503655bda80008cc08b23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c65616e69717565636f646572732f6c61726176656c2d636f6e6669672d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/laravel-config-backup)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b88cff76014665ba23468c8ad6546cda3d8e5af414e7541bc515cd4dd9d231b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f6c61726176656c2d636f6e6669672d6261636b75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/laravel-config-backup/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c4155145ece0acf6c8b439032920452a45c1784488351210bdc8bb4b01605f74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c65616e69717565636f646572732f6c61726176656c2d636f6e6669672d6261636b75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/laravel-config-backup)

Back up and restore your Laravel application **configuration** — the `.env` file and database-stored settings — as a single **portable, AES-256 password-encrypted ZIP**.

The archive stores its contents **decrypted**, so on import every encrypted database column is **re-encrypted with the destination server's `APP_KEY`**. That makes a backup taken on one server restorable on another. Every restore takes an automatic **pre-restore safety snapshot** first, so you can always roll back.

Why
---

[](#why)

- **Disaster recovery** — capture your `.env` and DB-stored settings before a risky change.
- **Server migration** — move configuration between environments even when the `APP_KEY` differs.
- **Auditable** — each backup is a row with who/when/what, retained per your policy.

Features
--------

[](#features)

- 🔐 AES-256 password-encrypted archives (the password is never stored)
- 📦 Two sections: `env` (the `.env` file) and `database` (allowlisted DB-stored settings)
- 🔁 Portable across servers — DB columns re-encrypted with the destination `APP_KEY`
- 🛟 Automatic pre-restore safety snapshot
- 🔎 Preview/diff before restoring (added/changed/removed `.env` keys, `APP_KEY`-change warning)
- 🧹 Retention pruning
- 🖥️ Artisan commands, optional scheduler, optional Livewire + Flux UI, and notifications

Installation
------------

[](#installation)

```
composer require cleaniquecoders/laravel-config-backup
```

Publish and run the migration:

```
php artisan vendor:publish --tag="laravel-config-backup-migrations"
php artisan migrate
```

Publish the config:

```
php artisan vendor:publish --tag="laravel-config-backup-config"
```

> **Store archives on a private disk.** They contain every secret. The ZIP itself is encrypted, but never expose it on a public disk.

The `database` section (allowlist)
----------------------------------

[](#the-database-section-allowlist)

Out of the box only the `env` section has anything to back up. To include database-stored settings, register the models in `config/config-backup.php`. Rows are exported through each model's casts (so encrypted columns are decrypted) and re-imported via `updateOrCreate`(matched on `match`), which re-encrypts them with the active `APP_KEY`:

```
'database' => [
    'settings' => [
        'model' => \Spatie\LaravelSettings\Models\SettingsProperty::class,
        'match' => ['group', 'name'],
    ],
    // 'sso_providers' => ['model' => \App\Models\SsoProvider::class, 'match' => ['uuid']],
],
```

Usage
-----

[](#usage)

### Programmatically

[](#programmatically)

```
use CleaniqueCoders\ConfigBackup\Facades\ConfigBackup;

// Create an encrypted backup of both sections.
$backup = ConfigBackup::create(['env', 'database'], 'a-strong-password');

// Inspect an archive before applying it.
$absPath = Storage::disk($backup->disk)->path($backup->path);
$preview = ConfigBackup::preview($absPath, 'a-strong-password');

// Restore selected sections (takes a safety snapshot first).
$result = ConfigBackup::restore($absPath, 'a-strong-password', ['env', 'database']);
```

### Artisan

[](#artisan)

```
# Create (password also reads from config-backup.schedule.password)
php artisan config-backup:create --sections=env,database --password=secret --notes="before upgrade"

# Restore an existing backup by UUID, or an external file
php artisan config-backup:restore {uuid} --password=secret
php artisan config-backup:restore --file=/path/to/backup.zip --password=secret --sections=env

# Prune beyond the retention count
php artisan config-backup:prune
```

### Scheduled backups

[](#scheduled-backups)

Enable in config (`config-backup.schedule.enabled`) and set a password. The package registers a scheduled `config-backup:create` plus a daily prune automatically.

### Notifications

[](#notifications)

Set `config-backup.notifications.enabled` and a recipient list in `config-backup.notifications.mail` to be emailed when a backup completes or fails.

### Web UI (optional)

[](#web-ui-optional)

If your app has [Livewire](https://livewire.laravel.com) and [Flux](https://fluxui.dev), a management screen is available at the configured route (`config-backup.route.prefix`, default `admin/config-backup`). Protect it with the `config-backup.gate` ability and/or route middleware.

Restoring after an `APP_KEY` change
-----------------------------------

[](#restoring-after-an-app_key-change)

When the restored `.env` carries a different `APP_KEY`, the package swaps the active encrypter mid-request so DB settings are re-encrypted with the **final** key, fires the `ConfigRestored` event (with `appKeyChanged: true`), and clears the config/cache. You may need to sign in again. Listen for `ConfigRestored` to flush any application-specific caches.

Testing
-------

[](#testing)

```
composer test
```

Local development (Testbench workbench)
---------------------------------------

[](#local-development-testbench-workbench)

The package ships a [Testbench](https://packages.tools/testbench) workbench — a real Laravel app with the package installed — so you can exercise it end-to-end. It seeds an admin user and three encrypted `settings` rows registered in the database allowlist.

```
# Build the workbench app (creates the sqlite db, migrates, seeds)
vendor/bin/testbench workbench:build
vendor/bin/testbench migrate:fresh --seed --seeder='Workbench\Database\Seeders\DatabaseSeeder'

# Drive the feature from the CLI
vendor/bin/testbench config-backup:create --sections=env,database --password=secret-pass --notes="manual test"
vendor/bin/testbench config-backup:restore  --password=secret-pass --force
vendor/bin/testbench config-backup:prune --keep=2

# Serve the app (welcome page + management UI at /admin/config-backup)
composer serve
```

> The management UI renders with Flux components — install `livewire/flux` in the workbench to view it. The CLI and service work without it.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nasrul Hazim Bin Mohamad](https://github.com/nasrulhazim)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57069d0f4b634f65eccc6e5d5848990e25968d45ec2cf46d626c6a4658f944b?d=identicon)[nasrulhazim.m](/maintainers/nasrulhazim.m)

---

Top Contributors

[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (6 commits)")

---

Tags

laravelconfigurationSettingsencryptionbackupenvrestoreCleanique Coderslaravel-config-backup

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cleaniquecoders-laravel-config-backup/health.svg)

```
[![Health](https://phpackages.com/badges/cleaniquecoders-laravel-config-backup/health.svg)](https://phpackages.com/packages/cleaniquecoders-laravel-config-backup)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

436834.4k1](/packages/clickbar-laravel-magellan)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

24740.3k](/packages/harris21-laravel-fuse)

PHPackages © 2026

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