Migrating Your Existing Database to PostgreSQL On Your VPS

  • Dump existing data on local system :
  (local_project_env) $ python manage.py dumpdata > dump.json
  • Move the dump.json file from your local system to VPS using either github or secure copy(scp).
  • Run the python shell and remove contentType data :

            (Note: Run the following commands on server’s terminal (ssh))

  (project_env) $ python manage.py shell 
   >>> from django.contrib.contenttypes.models import ContentType
   >>> ContentType.objects.all().delete()
   >>> quit
  • Load the dump.json file to your database:
  (project_env) $ python manage.py loaddata dump.json

Hosting Your Django Website on a CentOS VPS

Hosting any website/web application on a live server can sometimes become difficult if proper steps are not taken while deploying it. There are mainly 3 different types of hosting:

  1. Shared Hosting – Usually used for small (single page) websites with limited traffic.
  2. VPS Hosting – VPS ( Virtual Private Server ) hosting is used for websites with good amount of content and medium to high traffic.
  3. Dedicated Hosting – This hosting is generally used for large business websites with a lot of content and high traffic.

In this article, we will be discussing mainly about VPS hosting.

Similar Reads

VPS

VPS or Virtual Private Server is a single physical machine used by many of its users. A physical server somewhere in the world equipped with virtualization serves its users as a separate dedicated system for them to use. It divides the available resources among the different users and for each of its users, it appears as if they are using a separate dedicated machine....

Root Access & SSH

When you buy a VPS, you will be provided with the root login credentials. There are some hosting providers that have inbuilt terminal which can be used with root access. In that case, SSH is generally not needed....

Getting Ready For Deployment

Install all the required packages and libraries by verifying their versions with your local environment. Also download the softwares required for running you website....

Setting Up Your Website Database On Your VPS

Create your database and new role (database user) for the website using psql and update your settings.py file accordingly. Run the following command on your ssh terminal to create migrations for your database :...

Resetting Migration History On Local System

See the current migrations using command :...

Migrating Your Existing Database to PostgreSQL On Your VPS

Dump existing data on local system :...