Primo Committ

This commit is contained in:
paoloar77
2024-05-07 12:17:25 +02:00
commit e73d0e5113
7204 changed files with 884387 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
title: Advanced Usage
weight: 5
---

View File

@@ -0,0 +1,39 @@
---
title: Adding extra files to a backup
weight: 1
---
The package ships with a BackupManifestWasCreated event that enables you to add additional files to the backup zip file.
When backup process starts, the package will create a manifest of all file that are selected for backup. Once the manifest has been created, a zip file is made containing all the files in the manifest. The zip file will be copied to the backup destinations you configured.
However, if you have cases where you need to add additional files to a particular backup, you can do so, between the creation of the manifest and the creation of the zip file.
Right after the manifest is created and **before** the zip file is created the `Spatie\Backup\Events\BackupManifestWasCreated` event is fired. This is what is looks like:
```
namespace Spatie\Backup\Events;
use Spatie\Backup\Tasks\Backup\Manifest;
class BackupManifestWasCreated
{
/** @var \Spatie\Backup\Tasks\Backup\Manifest */
public $manifest;
public function __construct(Manifest $manifest)
{
$this->manifest = $manifest;
}
}
```
You can use that event to add extra files to the manifest as in the example below where the extra files are passed as an array to the addFiles() method.
```php
use Spatie\Backup\Events\BackupManifestWasCreated;
Event::listen(BackupManifestWasCreated::class, function (BackupManifestWasCreated $event) {
$event->manifest->addFiles([$path1, $path2, ...]);
});
```

View File

@@ -0,0 +1,12 @@
---
title: Backing up a non-laravel application
weight: 2
---
This package is tailor-made for use inside Laravel applications. But with a little bit of good will you can use it to backup non-Laravel applications as well.
To do so install Laravel on the same server where your non-Laravel application runs. In the Laravel app you'll have to install this package using the [installation instructions](/laravel-backup/v6/installation-and-setup). In the `app/config/backup.php`configuration file specify the paths of the non-laravel application you wish to backup in the `backup.source.files.include` key.
Do not forget to configure the database as well. In `app/config/databases.php` put the credentials of the database used by the non-Laravel application.
When running `php artisan backup:run` on the command line, the application will be backed up.

View File

@@ -0,0 +1,31 @@
---
title: Binary database dumps with PostgreSQL
weight: 3
---
PostgreSQL has the ability to produce binary database dumps via the `pg_dump` command, which produce smaller files than the SQL format and are faster to restore. See the [full list](https://www.postgresql.org/docs/current/app-pgdump.html) of `pg_dump` flags.
To take advantage of this, you can set the extra flags for `pg_dump` on the database connection(s) in `app/config/database.php`.
```php
//config/database.php
'connections' => [
'pgsql' => [
'driver' => 'pgsql'
...,
'dump' => [
...,
'add_extra_option' => '--format=c', // and any other pg_dump flags
]
],
```
Additionally, you can change the file extension of the database dump file to signify that it is not a text SQL file.
```php
//config/backup.php
'backup' => [
...,
'database_dump_file_extension' => 'backup', // produces a FILENAME.backup database dump
],
```

View File

@@ -0,0 +1,22 @@
---
title: Encrypt backup archives
weight: 4
---
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/).