nyoncode/laravel-backup-manager

nyoncode/laravel-backup-manager

Powerful and extensible backup manager for Laravel applications: databases, files, encryption, integrity manifests and multi-destination storage.

0
Packagist stažení
0
Verzí
1.1.1
Aktuální verze
Závislosti
php ^8.3 ext-json * ext-openssl * illuminate/bus ^12.0|^13.0 illuminate/console ^12.0|^13.0 illuminate/contracts ^12.0|^13.0 illuminate/database ^12.0|^13.0 illuminate/filesystem ^12.0|^13.0 illuminate/queue ^12.0|^13.0 illuminate/support ^12.0|^13.0 nyoncode/laravel-package-toolkit ^2.1.1 symfony/finder ^7.0 symfony/process ^7.0

Getting started

This tutorial takes you from nothing to a real, verified backup that you can restore — in about ten minutes. Follow it top to bottom; each step is a command you run and the output you should see.

By the end you'll have created a backup, inspected it, confirmed its integrity, restored it, and know how to make it production-ready.

What you'll do

  1. Install the package into a Laravel app.
  2. Create your first backup.
  3. See what was stored.
  4. Verify the backup can be trusted.
  5. Restore it — safely.
  6. Make it production-ready: encrypt it, send it off-site, and run it on a schedule.

Before you start

You need an existing Laravel 12 or 13 application and PHP 8.3+. If you back up a database, its command-line tools (for example mysqldump for MySQL) must be installed. The full list is on the Installation page — but for a first run against SQLite or files only, you need nothing extra.

1. Install the package

From your application's root, require the package and publish its config:

1composer require nyoncode/laravel-backup-manager
2php artisan vendor:publish --tag="backup-manager-config"

That's it — Laravel registers the package automatically, and you now have a config/backup-manager.php file. The defaults back up your whole application (database + files) to local storage, which is perfect for this tutorial.

2. Create your first backup

Run the default backup:

1php artisan backup:run

You'll see a summary of what was captured:

1 INFO Running backup for profile [default]….
2
3Archive ............ default-2026-07-19-020000-a1b2c3.tar.gz
4Mode ............... Archive
5Size ............... 4.72 MB
6Databases .......... 1
7Files .............. 128
8Destinations ....... local
9
10 INFO Backup completed successfully.

You just created your first backup. It lives on the local disk under the backups/ folder.

3. See what was stored

List the backups the package knows about:

1php artisan backup:list

Each backup is two files: the archive itself (a compressed .tar you can optionally encrypt) and a *.manifest.json next to it. The manifest is a plain, unencrypted record of what's inside — the environment, the checksum of the archive, and a hash of every file — so a backup can be checked and trusted on its own, even without this package.

4. Check it can be trusted

A backup is only worth having if it isn't corrupted. Verify the newest one against its manifest:

1php artisan backup:verify
1 INFO Verifying backup [default-2026-07-19-020000-a1b2c3]….
2
3Archive checksum ... OK
4Files ............. 128/128 verified
5
6 INFO Backup is valid.

5. Restore it

Restoring puts the backup's contents back. Try it:

1php artisan backup:restore

The command asks you to confirm, then verifies the archive before touching anything. By default it also takes a pre-restore snapshot and rolls everything back automatically if the restore fails — so a bad restore never leaves you worse off than before. You can restore just the database or just files; see Restore for the options.

Try restores on staging first. Restoring overwrites current data with the backup's data — that's the whole point, so run it where you mean it.

6. Make it production-ready

A local, unencrypted backup is a great start. Three changes turn it into something you'd trust in production:

  • Encrypt it. Set an algorithm and a key so the archive is unreadable at rest. See Security & the manifest.
  • Send it off-site. A backup on the same server as your app disappears with the server. Add an S3 (or FTP/SFTP/…) disk to the profile's destinations and write to both at once. See Storage destinations.
  • Run it automatically. Turn on the built-in schedule so backups, cleanup and health checks happen without you. See Scheduling & monitoring.

For example, in config/backup-manager.php:

1'profiles' => [
2 'default' => [
3 // …
4 'destinations' => ['s3', 'local'], // off-site + a local copy
5 ],
6],
7'encryption' => [
8 'algorithm' => 'aes-256-gcm',
9 'key' => env('BACKUP_ENCRYPTION_KEY'), // 32 bytes, base64: accepted
10],
11'schedule' => ['enabled' => true],

Where to go next