Spatie Laravel Backup and Envoyer
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
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:
/path/to/application .env current -> /path/to/application/releases/20151209090624/ releases/ 20151208123356/ 20151208162332/ 20151209083721/ 20151209090624/ .env -> /path/to/application/.env storage -> /path/to/application/storage/ app/ bootstrap/ ... 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.