Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm a programmer by trade, "server administrator" by company necessity.

We're looking at dumping the old painful "update site by FTP upload" style of deployment. Having the webserver check out the latest code base from version control into a folder and having a "current" symlink point to the latest checkout (allowing for easily stepping back to an older version by changing the symlink) seems to be the way we want to go.

But I have a question: what's a good practice for dealing with user-uploaded content? This stuff isn't in version control. I have a couple of ideas for dealing with this, but what is the smart, accepted practice?

share|improve this question
add comment

5 Answers

If the uploaded content is all in one directory, I can see two ways.

  • Make the uploaded directory a symlink is version control. Have that symlink point to the destination directory for actual uploads.
  • Setup an Alias in your website config to point to the actual directory that is outside the normal webroot.

The first method requires no real code changes, while the 2nd method seems a bit cleaner to me.

share|improve this answer
add comment

User-uploaded content should not be placed in version control, as you mentioned. However, they should still be backed up.

I recommend simply setting up a daily cron backup script that would rsync, tar, rdiff-backup, or whatever, and upload the data to another server. Of course, the approach you take would depend on the importance of your data; for truly critical information, you may want to set up instant replication (for databases especially: read up on database replication).

share|improve this answer
add comment

I only deal with images and avatars for user-content. As well as a load balanced web severs. I relegate all uploaded content to one web server, that is backed up daily. I then setup a rsync server on the content server. The web servers request the new files via rsync every minute on a cronjob. All the files are then replicated and backed up!

share|improve this answer
add comment

You should place it somewhere outside webserver root, /var/upload/ for example. It has security considerations: webserver code must not be exposed to uploaded code, and it can happen, if you mix these two things and set wrong permissions. And you keep your content between upgrades.

If users upload small files, the best way is to store them in database.

share|improve this answer
add comment

I suspect you may be over thinking this a bit. While the preferred option is to simply have the web content and the uploaded files isolated, you could also just exclude the upload directory (and sub-directories?) from the version control.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.