Re: Moving a Django website to another server

1,558 views
Skip to first unread message

Oscar Carballal

unread,
Jan 25, 2013, 10:22:07 AM1/25/13
to django...@googlegroups.com
For our project e-cidadania it was like that, we only had to make a
clone of the git repository and we made a symbolic link to the config
files (so we can pull the code without affecting the config). After
that we made an import into the new database, fix the config files et
voilá.

You can try SSH if you have it available, via the "scp" command, it's
faster and easier in my opinion, but if you only have the FTP
available you should take care of the file permissions and user/group.

Regards,
Oscar Carballal

2013/1/25 John Robertson <linksstr...@gmail.com>:
> Hi there, if I want to move a Django website to another host, is it as
> simple as copying across all the site files and DB (and changing config
> files)? If so, is there some kind of tool to create a zipped folder of the
> website so that FTP does not take several hours! Sorry if this seems a very
> basic question, but I just wanted to check before I proceed with it. They
> are fairly simple, small sites, but still there are thousands of files.
>
> Many thanks!
> John
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Bill Freeman

unread,
Jan 25, 2013, 12:31:39 PM1/25/13
to django...@googlegroups.com
What kind of hosts?  if both are linux, then tar is your friend, using the -z or -j options
to create compressed archives, though zip and unzip commands are likely available
too.  If you use ftp (faster, but less secure than scp/sftp), be sure to transfer in binary
mode (text is the default, and will cause problems for bytes in the compressed file
that look like carriage return or line feed).

Whether it is just a matter of copying "everything" depends on how compatible the
two machines are.  For example, if you are using the system's base python, rather
than installing one of your own, and the two are different versions, they .pyc files
will not be compatible.  Also, if you installed django and other apps naively, they
may be in directories that you aren't copying.  It is also possible that there are
dependencies (libraries linked against by the egg installers) that are missing
or incompatible on the new box.  There are also presumably http server and
database servers that need to be installed, and which have configuration files.
So, unless you're cloning the whole OS install onto a compatible piece of hardware
(and even there you should do things like fix up the network configuration and
ssh machine keys) I think that you're going to have trouble "just copy"ing.

Bill

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.

Oscar Carballal

unread,
Jan 25, 2013, 12:34:03 PM1/25/13
to django...@googlegroups.com
Bill has a point, I assumed both were VPSs that had the same services,
software and directory structures. If you change that, then it will be
a bit more of work :)

2013/1/25 Bill Freeman <ke1...@gmail.com>:

Adrián Espinosa

unread,
Jan 25, 2013, 8:04:59 PM1/25/13
to django...@googlegroups.com
If both hosts are Linux, you can use "rsync -avuzr source destination". Option -z enables compression 

Addy Yeow

unread,
Jan 25, 2013, 8:39:51 PM1/25/13
to django...@googlegroups.com
I was looking for a consistent and error-free deployment as I switch
between servers frequently despite using the same public domain. rsync
was great but I had to manually reload server thereafter or issue a
syncdb, etc.

I have since moved to Fabric for my deployment needs. See
http://docs.fabfile.org/en/1.5/tutorial.html.
With Fabric, I only need to issue one command for daily deployment to
existing or new server, e.g. fab deploy, under my Django project
directory to deploy the project.

Sanjay Bhangar

unread,
Jan 27, 2013, 12:20:40 AM1/27/13
to django...@googlegroups.com
On Sat, Jan 26, 2013 at 7:09 AM, Addy Yeow <aye...@gmail.com> wrote:
> I was looking for a consistent and error-free deployment as I switch
> between servers frequently despite using the same public domain. rsync
> was great but I had to manually reload server thereafter or issue a
> syncdb, etc.
>
> I have since moved to Fabric for my deployment needs. See
> http://docs.fabfile.org/en/1.5/tutorial.html.
> With Fabric, I only need to issue one command for daily deployment to
> existing or new server, e.g. fab deploy, under my Django project
> directory to deploy the project.
>

Just to second this - there are several articles on the interwebs
about using fabric, virtualenv and pip for managing your dependencies
and deployments. I have found this to be an incredibly smooth way to
manage things. The only sometimes nasty thing about moving stuff from
one server to another is installing all the dependencies you need for
your django project to run - 3rd party apps, python packages you need,
etc. One situation that can occur frequently is that if you install a
dependency on the new server, it gets a later version of the package,
and this breaks something on your code which depends on some behaviour
of an older version. To tackle this, I've found 'pip freeze' to be
great - you type 'pip freeze' in the virtualenv of your working
project code, and it lists all the python packages the project is
using with their exact versions, so you can use this to create a
requirements.txt file to 'pip install -r requirements.txt' from on the
new server while making sure it gets the very exact version of
dependencies so you can be sure it is running the same code -- in
general, I have found this to be the smoothest way to deploy projects
onto new servers.

hth,
Sanjay

John Robertson

unread,
Jan 31, 2013, 4:09:52 AM1/31/13
to django...@googlegroups.com
Hi there, thanks for all your very helpful responses. Its all a little out of my comfort zone so I might employ someone to do it for me. Any takers/quotes?

cheers
John

Avraham Serour

unread,
Jan 31, 2013, 7:47:45 AM1/31/13
to django...@googlegroups.com
similar question on the same topic:

I used dumpdata/loaddata to move from sqlite to postgres, while it was able to move the relations it didn't get any image, any way I could something similar but including the images?

would south be able to do it?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Kelly Nicholes

unread,
Jan 31, 2013, 9:45:36 AM1/31/13
to django...@googlegroups.com
If you're storing your images in your database (don't) then your db migration should have done it.  If you're storing the paths in the database, let's hope they're relative paths to the images.  You'll have to copy the images to your new server using the same approaches listed above.  One alternative is to have a separate server that serves all of your static media, then your paths can stay the same, regardless of which server(s) your database(s)/code is on.

Mike Doroshenko II

unread,
Jan 31, 2013, 11:57:20 AM1/31/13
to django...@googlegroups.com
I have scripts that use rsync for my backups, this is old hat for me lol :)

John Robertson wrote:
Hi there, thanks for all your very helpful responses. Its all a little out of my comfort zone so I might employ someone to do it for me. Any takers/quotes?

cheers
John

On Friday, January 25, 2013 10:20:49 AM UTC, John Robertson wrote:
Hi there, if I want to move a Django website to another host, is it as simple as copying across all the site files and DB (and changing config files)? If so, is there some kind of tool to create a zipped folder of the website so that FTP does not take several hours! Sorry if this seems a very basic question, but I just wanted to check before I proceed with it. They are fairly simple, small sites, but still there are thousands of files.

Many thanks!
John
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
-- 
Mike Doroshenko, Junior Sys Admin
TecKnoQuest Inc.
mi...@tecknoquest.com
www.tecknoquest.com

Avraham Serour

unread,
Jan 31, 2013, 12:16:32 PM1/31/13
to django...@googlegroups.com
Just checked the docs, looks like ImageField stores the path

it was a satchmo app, does someone knows what it does with the product images?

thanks
avraham
Reply all
Reply to author
Forward
0 new messages