Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version control of uploaded images to file system

After reading Storing Images in DB - Yea or Nay? I think that the file system is the right place for storing images. But I would like to know how you handle backup/version control of uploaded images in your different environments (dev/stage/prod) and for network load balancing?

These problems is pretty easy to handle when working with a database e.g. to make a backup from the production environment and restore the DB in the development environment.

What do you think of using for example git to handle version control of uploaded files e.g?

Production Environment:

  • A image is uploaded to a shared folder at the web server.
  • Meta data is stored in the database
  • The image is automatically added to a git repository

Developer at work:

  • Checks out the source code.
  • Runs a script to restore the database.
  • Runs a script to get the the latest images.

I think the solution above is pretty smooth for the developer, the images will be under version control and the environments can be isolated from each other.

like image 215
orjan Avatar asked Dec 07 '09 20:12

orjan


People also ask

How can I store my uploaded photos?

Store the images as a file in the file system and create a record in a table with the exact path to that image. Or, store the image itself in a table using an "image" or "binary data" data type of the database server.

Can git be used with images?

Raster images and music files make as much sense to Git as they would to you if you looked at the binary data contained in a . png or . wav file. So Git just takes all the data and makes a new copy of it, even if only one pixel changes from one photo to the next.

What is the best way to store images in a database?

To insert images into a database, the database must support images. Images are stored in binary in a table cell. The data type for the cell is a binary large object (BLOB), which is a new SQL type in SQL3 for storing binary data.


1 Answers

For us, the version control isn't as important as the distribution. Meta data is added via the web admin and the images are dropped on the admin server. Rsync scripts push those out to the cluster that serves prod images. For dev/test, we just rsync from prod master server back to the dev server.

The rsync is great for load balancing and distribution. If you sub in git for the admin/master server, you have a pretty good solution.

If you're OK with backup that preserves file history at the time of backup (as opposed to version control with every revision), then some adaption of this may help: Automated Snapshot-style backups with rsync.

like image 68
Matt Avatar answered Sep 24 '22 06:09

Matt