Encrypt backup archives | laravel-backup | Spatie

 SPATIE

  Laravel Backup
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup](https://spatie.be/docs/laravel-backup/v6)  Advanced-usage  Encrypt backup archives

 Version   v10   v9   v8   v7   v6   v5   v4   v3

 Other versions for crawler [v10](https://spatie.be/docs/laravel-backup/v10) [v9](https://spatie.be/docs/laravel-backup/v9) [v8](https://spatie.be/docs/laravel-backup/v8) [v7](https://spatie.be/docs/laravel-backup/v7) [v6](https://spatie.be/docs/laravel-backup/v6) [v5](https://spatie.be/docs/laravel-backup/v5) [v4](https://spatie.be/docs/laravel-backup/v4) [v3](https://spatie.be/docs/laravel-backup/v3)

- [ Introduction ](https://spatie.be/docs/laravel-backup/v6/introduction)
- [ Support us ](https://spatie.be/docs/laravel-backup/v6/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-backup/v6/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup/v6/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup/v6/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-backup/v6/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-backup/v6/changelog)
- [ About us ](https://spatie.be/docs/laravel-backup/v6/about-us)

Taking Backups
--------------

- [ Taking backups ](https://spatie.be/docs/laravel-backup/v6/taking-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup/v6/taking-backups/events)

Cleaning up old backups
-----------------------

- [ Cleaning up old backups ](https://spatie.be/docs/laravel-backup/v6/cleaning-up-old-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup/v6/cleaning-up-old-backups/events)

Monitoring the health of all backups
------------------------------------

- [ Monitoring the health of all backups ](https://spatie.be/docs/laravel-backup/v6/monitoring-the-health-of-all-backups/overview)
- [ Creating your custom health check ](https://spatie.be/docs/laravel-backup/v6/monitoring-the-health-of-all-backups/creating-your-custom-health-check)
- [ Events ](https://spatie.be/docs/laravel-backup/v6/monitoring-the-health-of-all-backups/events)

Sending notifications
---------------------

- [ Sending notifications ](https://spatie.be/docs/laravel-backup/v6/sending-notifications/overview)
- [ Adding extra notification channels ](https://spatie.be/docs/laravel-backup/v6/sending-notifications/adding-extra-notification-channels)
- [ Customizing the notifiable ](https://spatie.be/docs/laravel-backup/v6/sending-notifications/customizing-the-notifiable)

Advanced Usage
--------------

- [ Adding extra files to a backup ](https://spatie.be/docs/laravel-backup/v6/advanced-usage/adding-extra-files-to-a-backup)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup/v6/advanced-usage/backing-up-a-non-laravel-application)
- [ Binary database dumps with PostgreSQL ](https://spatie.be/docs/laravel-backup/v6/advanced-usage/binary-database-dumps-with-postgresql)
- [ Encrypt backup archives ](https://spatie.be/docs/laravel-backup/v6/advanced-usage/encrypt-backup-archives)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-backup                                                                                                                                                                                                                                    `

Encrypt backup archives
=======================

It's common to encrypt backups before storing them somewhere to prevent unauthorized access. To do so you can configure this package to use client-side symmetric zip file password encryption before storing the archive somewhere.

By default you only have to define the `BACKUP_ARCHIVE_PASSWORD` environment variable in your `.env` file.

If you want to customize this you can configure the `backup.backup.password` and `backup.backup.encryption` keys in your `config/backup.php` file.

The whole encryption is done with an event listener. The `\Spatie\Backup\Listeners\EncryptBackupArchive` listener is attached to the `\Spatie\Backup\Events\BackupZipWasCreated` event. The listener is added to the event when both required config keys are not `null`. You are free to add this listener your own or override it.

It's important to try this workflow and also to decrypt a backup archive. So you know that it works and you have a working backup restore solution.

**Warning:** the default MacOS app to (un)archive ZIPs seems unable to open/extract encrypted ZIP files. You should use an app like [The Unarchiver](https://theunarchiver.com/) or [BetterZip](https://macitbetter.com/).
