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

feralheart's avatar

Save to cloud vs use git

I made a site in Laravel where the users can upload some files (for example images). I configuring the backup right now and I'm thinking about how to backup these files?

Should I put these in a cloud filesystem or use git? The files are all in the public folder

0 likes
4 replies
lostdreamer_nl's avatar

git is only for your code changes, not user uploads ;)

backup the user & DB data to a different partition or server via scheduled jobs.

1 like
lostdreamer_nl's avatar

you could yes, just set it up as a disk (config/filesystems.php) and create a script that goes over all files in your upload folder, and put them into that disk.

If it's really just for backup purpose, I would probably just create a small script and run it via cron.

The script would then do an incremental backup, zip/tar it up and push it to another server.

1 like
Cronix's avatar
Cronix
Best Answer
Level 67

I'd just store/upload the images to an AWS S3 bucket and not your local server to begin with. You can turn replication on so they are always backed up in a separate region automatically, and no need to manually back them up.

We do this with our images, as well as use their database services that do the same thing, so we don't have to backup our images or db. We do keep a monthly snapshot of the db separate just in case, but have NEVER needed to restore a backup in the 6 years we've been doing it. The db has failed once, due to a hardware problem on that physical server (it happens!), and I'm sure glad we used that service, because AWS automatically switched to the backup db almost instantly while it rebuild the main db in the background. We only had about 2 minutes of actual downtime. Had that been our only db instance and we had to restore it from files, that literally could have taken 5 or 6 HOURS (we have a lot of data).

The only thing we have on our app servers, is the actual code. No assets or data. We can just throw away a server, build up a new on, deploy our code and away we go. All in a few minutes. If you have to restore tons of images and the database, that process could take a very long time.

2 likes

Please or to participate in this conversation.