LaravelWeb Development

Backing up Laravel Applications

By February 27, 2016 No Comments

If you’re not backing up your websites in production, you should be. Be prudent with your backups so that when data loss happens, you can recover quickly and easily.

All projects that I work on are version controlled, meaning that the project files are automatically backed up to a remote repository. Though the solutions I go through include file backups, I’m going to focus on database backups.

Two ways to perform a backup

The backup systems that I’ve experimented with can be divided into two types.

  1. The application handles backing itself up through the code, or
  2. A dedicated external service handles the backup.

Self Handling Backups

I use Spatie’s Laravel Backup package to take care of my self handling backups. It’s easy to set up and allows you to save your database (and file) backups offsite to any of the file systems that you have configured in Laravel 5. Additional features are promised in the next major release which should happen sometime in March.

An alternative package that I haven’t tried myself, but seems to be popular on GitHub is the framework agnostic Backup Manager. It comes with a Laravel Driver that makes it trivial to set up and get your backups going in minutes.

External Backup Service

An external service makes backing up multitudes of websites easier, and gives you a single dashboard to handle all your backups. I’ve recently tried out two similar ones: Ottomatik and BitCan.

Ottomatik

Ottomatik is a service targeted specifically to Laravel apps. It requires you to install a small application on your server before you can start configuring your backups. Once you get that out of the way it offers you a fluent interface to configure and schedule your backups, and optionally store them on your own S3 account.

It’s easy to set up, and at a glance you can see the status of your backups. Having your backups stored on your own S3 account means you can set it and forget it, and happily access your backups directly through S3.

The only downside that I can see to this service is that many of the more useful features are only available when on the higher priced plans, and if you have many websites to backup, you could be quickly forced into paying more.

BitCan

BitCan allows you to configure servers either by installing an application (similar to Ottomatik’s) or by installing their public SSH key. I went for the public key approach as it allows me to easily remove it from my server in the future should I ever wish to.

BitCan’s interface isn’t as intuitive and responsive as I would have liked, but I was able to easily and quickly configure and schedule a number of backups. All backups get saved to their hosted system.

Happily, BitCan’s pricing structure is based on storage, not number of backups, so depending on your use case can turn out to be a very cost effective solution.

Which should I choose?

If you need to backup just a few websites and have an S3 account, I recommend the free self handling method. Laravel Backup and Backup Manager will both do the job for you here.

If you have many websites that you’ve got to backup and the ability to handle them all from one place is a deciding factor, then an external backup service is more suited to your needs.

Of the two services that I tried, BitCan was a more cost effective solution, even though Ottomatik’s ability to upload to your own S3 account would have been a nice feature to have!

Michael Stivala

Michael Stivala

An inspired creative professional.