Django Archive

Django Archive provides a management command that will create a compressed archive of database tables and uploaded media.

Contents

Installation

Django Archive is distributed as a Python package through PyPI.

PyPI Package

Installation on most platforms consists of running the following command:

pip install django-archive

Project Setup

Once the package is installed, it must be added to INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    'django_archive',
)

Usage

Interacting with Django Archive is done through a set of management commands.

Creating an Archive

To create an archive, use the archive management command:

python manage.py archive

This will create a compressed archive in the current directory containing a single fixture in JSON format and all uploaded media.

Settings

Django Archive provides a number of settings that can be used to customize its behavior. These settings are optional, but may be modified on a per-project basis in the project’s settings.py.

ARCHIVE_DIRECTORY
Default:empty

Path to a directory where the archives will be stored. The default behavior is to create the archive in the current directory.

ARCHIVE_FILENAME
Default:'%Y-%m-%d--%H-%M-%S'

String passed to strftime() to determine the filename of the archive that will be generated.

ARCHIVE_FORMAT
Default:django_archive.archivers.TARBALL_BZ2

Format used for creating the compressed archive. The options currently available include:

  • django_archive.archivers.TARBALL
  • django_archive.archivers.TARBALL_GZ
  • django_archive.archivers.TARBALL_BZ2
  • django_archive.archivers.TARBALL_XZ
  • django_archive.archivers.ZIP

The predefined constants enable you to easily specify the archive format in your settings.py:

from django_archive import archivers
ARCHIVE_FORMAT = archivers.ZIP
ARCHIVE_EXCLUDE
Default:
(
    'contenttypes.ContentType',
    'sessions.Session',
    'auth.Permission',
)

List of models to exclude from the archive. By default, this includes session data and models that are automatically populated.

Indices and tables