'Backup strategy ubuntu laravel

I am searching for a backup strategy for my web application files.

I am hosting my (laravel) application at an ubuntu (18.04) server in the cloud and currently have around 80GB of storage that needs to be backed up (this grows fast). The biggest files are around ~30mb, the rest of it are small jpg/txt/pdf files.

I want to make at least 2 times a day a full backup of the storage directory and store it as a zip file on a local server. I have 2 reasons for this: independence from cloud providers, and for archiving.

My first backup strategy was to zip all the contents of the storage folder en rsync the zip, this goes well until a couple of gigabytes then the server is completely stuck on cpu usage.

My second approach is with rsync, but this i can't track when a file is deleted / added.

I am looking for a good backup strategy that preferable generate zips before or after backup and stores them so we can browse and examine back in time.

Strange enough i could not find anything that suits me, i hope anyone can help me out.



Solution 1:[1]

I agree with @RobertFridzema that the whole server becomes unresponsive when using ZIP functionality from spatie package.

Had the same situation with a customer project. My suggestion is to keep the source code files within version control. Just backup the dynamic/changing files with rsync (incremental works best and fast) and create a separate database backup strategy. For example with MySQL/Mariadb: mysqldump, encrypt the resulting file and move it to an external storage as well.

If ZIP creation still is a problem, I would maybe use a storage which is already set up with raid functionality or if that is not possible, I would definitly not use the ZIP functionality on the live server. rsync incremental to another server and do the backup strategy there.

Solution 2:[2]

Spatie has a package for Laravel backups that can be scheduled in the laravel job scheduler. It will create zips with the entire project including storage dirs

https://github.com/spatie/laravel-backup

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 René Pardon
Solution 2 Marcus