Spatie Laravel Backup and Envoyer

laravel-logoTo setup automated backups for a Laravel application I decided to try out the Spatie Laravel Backup package. It can backup your application to all Laravel filesystems you have configured.

With this package you can configure which files you want to include and exclude in your backups. The default configuration of this package includes the base_path() directory and excludes the storage_path() and base_path('vendor') directories.

However, I have some files under the storage_path() directory that I do want to backup, so I modified my configuration to include those files. When I ran the backup locally everything worked fine, but when I tested it out on my production server the files in the storage_path() directory were missing.

After some digging around I found out that this came from the fact that I use Envoyer to deploy my application. Envoyer stores the last four releases and uses a symlink to point to the current release. It also uses symlinks for files/directories that should be shared between releases, for example the .env file and the storage_path() directory. The directory structure used by Envoyer looks something like this:

    current -> /path/to/application/releases/20151209090624/
            .env -> /path/to/application/.env
            storage -> /path/to/application/storage/

If you configure your backups to include the base_path() directory with the directory layout above, the files in the storage directory will not be included. This is because the call to base_path() will output the real path to the current release, which will be /path/to/application/releases/20151209090624/ for the example above. However, the storage_path() directory is not included in this path, since it is located at /path/to/application/storage/. That is why the files in the storage_path() directory were not included in my backups.

The fix for this problem is easy though, you can simply add the storage_path() directory to the list of included directories you configure for you backups and they will be included in your backups.

December 9, 2015

Click Here to Leave a Comment Below

olidev - August 25, 2017

Envoyer has made front-end devs life much easier. I too use cw+envoyer combination to deploy my PHP apps ( ) in less time than before. Envoyer is a nice addition to workflow of today’s devs.

Leave a Reply: