views:

47

answers:

2

I have django and django's admin setup on my production box. This means that all file uploads are stored on the production box, all the media is stored there.

I have a separate server for files now ( different box, ip ). I want to upload my files there. What are the advantages and disadvantages of these methods I've thought about, and are there "better" methods you can suggest?

  1. Setting up a script to do an rsync on the production box after a file is uploaded to the static server.
  2. Setting up a permanent mount on the production box, by using a fileserver on the static media box such as nfs/samba/ssh-fs and then using the location of the mount as the upload_to path on the production box

Information: Both servers run debian.

EDIT: Prometheus from #django suggested http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

+3  A: 

I use Fabric. Especially of interest to you would be fabric.contrib.project.rsync_project().

To Paraphrase -

Fabric is a Python library and command-line tool for streamlining the use of SSH for Application Deployment or systems administration tasks.

First use fabric.contrib.project.upload_project() to upload the entire project directory. From then on, bank on using fabric.contrib.project.rsync_project. to sync the project with local version. Also of special interest is that this uses unix rsync underneath & uses the secure scp to transfer .tar.gz data.

I guess this takes care of your needs. There might not be a need to setup a permanent mount etc.

MovieYoda
I only need this for static media though, I'm not actually deploying? Or did I misunderstand, and that stuff still applies?
meder
Oh, but you could still use the method I suggested to keep your static data in sync. It doesn't need to be a Django project only.
MovieYoda
MovieYoda
+1  A: 

If your static media is derived from your development process, then Fabric is the way to go. It can automate the deployment and replication of anything-- data, application files, even static database dumps-- from anywhere to anywhere.

If your static media is derived from your application server's operation-- generated PDFs and images, uploads from your users, compiled binaries (I had a customer who wanted that, a Django app that would take in raw x86 assembly and return a compiled and linked binary)-- then you want to use Django Storages, an app that abstracts the actual storage of content for any ImageField or FileField (or anything with a Python File-like interface). It has support for storing them in databases, to Amazon S3, via FTP, and a few others.

Elf Sternberg