Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

flo's avatar
Level 5

Back-up Forge server (Digital Ocean)

I was wondering how you are currently making sure you have a back-up of your important data on Forge server (e.g.):

  • Mysql (daily with x days retention)
  • User uploaded files (public/uploads/*)

Currently I'm using a daily back-up of the mysql by running a cronjob of https://github.com/schickling/laravel-backup but I'm still clueless on how to create a good retention policy and how to back-up just files of a specific folder (e.g. public/uploads/*).

0 likes
5 replies
MichaelDaly's avatar

I am interested in gaining knowledge on a backup policy similar to the one you raised here.

At the moment, I am doing a 'hack' job of backing up my mysql data and website through cron, rsync and storing offsite on local NAS box in my house - however, I would like a more elegant solution that can be easily monitored and easily restored if necessary.

If anyone has any tips or advice regarding this then I would be grateful for the help.

Thanks

fideloper's avatar

I don't think that's too hacky, other than possibly uploading to S3 instead of a local NAS. It depends on your needs. I upload to S3 on a cron job on my site, but I can afford for it to go down for a few hours or a day.

The key strategy to setting yourself up for a quick recovery is saving "state" away from servers which can be "stateless". If you can make your web server(s) stateless, you can easily rebuild them simply by creating a new server and putting your files on them (assuming they're PHP).

If you have a separated database server, it crashing will be separate from your web server crashing.

On a site generated revenue, or important to business, you may want to at least have some automation setup to setup a secondary server. Or you can have secondary servers pre-built and setup, just waiting.

Then you can decide on the best way to do data recovery (manually from backup files, or automated, perhaps by using database replication and having a way to promote a replica database to master).

There's lots of setups, but "high availability" tends to get expensive :D

As for user-uploaded files, I use S3 again - a central file storage will do wonders for you! This goes towards removing "state" from your web servers. Using S3 lets you not worry about where your uploads are - you can bring up new servers which connect to S3 via their API, rather than have to worry about recovering uploads and putting them back in the right place on your server.

Unfortunately I think the answer to your question is "spend some money", but at least S3 is cheap! I think I pay ~ $1-2 a month for about a years of database backups and some other random files.

jekinney's avatar

I guess this is a question more than a statement, but isn't cloud based solutions suppose to automatically cover redundancy incase of a failure?

I do backups through forge and scheduled commands just incase. Coming from C# and azure it was guaranteed feature.

Please or to participate in this conversation.