ποΈ Backups
The backups app saves a copy of your database on a schedule. Each backup is
a gzipped Django fixture in your media storage, such as an S3 bucket, and
the newest 14 are kept. Superusers see the backups on the
system status page, download them and back up on
demand on the Backups page. They restore a backup, or a file made with
dumpdata, on that page or with a management command.
Setupβ
Add the app to INSTALLED_APPS and migrate. It keeps a record of each
backup in its own table.
# settings.py
INSTALLED_APPS = [
# ...
"content_studio",
"content_studio.contrib.status",
"content_studio.contrib.backups",
]
python manage.py migrate
Backups go to the default storage, in the folder content_studio/backups,
every night at 03:00. On most sites the default storage is the media
storage, which the web server serves to anyone, so manage.py check stops
with content_studio.E052 until the backups have a private storage: see
Keep the backups private. Then decide what
runs them.
With Hueyβ
With Huey installed (huey.contrib.djhuey in
INSTALLED_APPS), the backups run as a Huey periodic task on
BACKUP_SCHEDULE. Nothing else is needed:
the consumer that runs your other tasks runs the backups.
Huey reads the schedule in UTC unless you set utc=False in your HUEY
settings, so "0 3 * * *" runs at 03:00 UTC.
With cronβ
Without Huey, run the backup command from cron on the same schedule:
# crontab -e
0 3 * * * cd /srv/blog && .venv/bin/python manage.py content_studio_backup
manage.py check then warns with content_studio.W028 that Huey does not
run the schedule. Once the cron job is in place, add the warning to
SILENCED_SYSTEM_CHECKS. The status page still uses BACKUP_SCHEDULE to
know when a backup is due.
Keep the backups privateβ
A backup holds the whole database, password hashes included. Anyone who can read the backup folder can read every account.
- S3 and other object storage: keep the bucket private and let the storage sign its URLs (django-storages' default). Content Studio never links to a backup; downloads go through the Backups page, for superusers.
- The file system: a web server that serves
MEDIA_ROOTalso serves the backups in it. Give the backups a storage of their own, outsideMEDIA_ROOT:
# settings.py
STORAGES = {
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"
},
"backups": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {"location": "/srv/blog/backups"},
},
}
CONTENT_STUDIO = {
# ...
"BACKUP_STORAGE": "backups",
}
manage.py check reports content_studio.E052, an error, when the backup
storage is a file system storage inside MEDIA_ROOT, or an object storage
with a public ACL or unsigned URLs. If your web server refuses the backup
folder, add content_studio.E052 to SILENCED_SYSTEM_CHECKS.
Each backup's name ends in a random token, so it cannot be guessed from the schedule. That is a second line of defence, not a reason to keep backups where they are served.
Backups are not encrypted by Content Studio. Turn on your storage's own encryption at rest, such as S3's default server-side encryption.
What a backup holdsβ
Each backup is the JSON that manage.py dumpdata writes, gzipped, with
natural keys for content types and permissions. It covers every model of
every installed app, so loaddata reads it back on any database engine.
Left out:
- Content types and permissions:
migratecreates them again. - Sessions: everyone signs in again after a restore.
- Password reset codes (
content_studio.contrib.password_reset): they are short-lived, and a backup should not hold codes that still work. - Captcha challenges and tokens (
content_studio.contrib.captcha), for the same reason. - The backup records themselves.
- Whatever you list in
BACKUP_EXCLUDE, as app labels ("analytics") or models ("shop.Cart"). - Models whose table is not in the database: an installed app that was
never migrated, or a model with
managed = Falsethat only stands in for an admin page. There is nothing to back up for them, and plaindumpdatawould stop at them. The backup logs a warning, lists them in its manifest underskippedand names them on the Backups page.
Media files are not part of a backup: they stay in the storage they are in. Protect them with the storage's own versioning or replication.
Tables without a modelβ
dumpdata only reads Django's models, so tables of another app that shares
the database, such as Umami's analytics, are not in a
backup, and a restore leaves them alone. Name them in
BACKUP_TABLES to back them up too:
# settings.py
CONTENT_STUDIO = {
# Umami in its own PostgreSQL schema (?schema=umami in its DATABASE_URL)
"BACKUP_TABLES": ["umami.*"],
# or Umami's tables next to Django's, in the public schema
"BACKUP_TABLES": ["website*", "session*", "event_data", "report", "_prisma_migrations"],
}
Each entry is a table name or a shell-style pattern (*, ?, [abc]),
looked up in the database's current schema, or "schema.table" for
another PostgreSQL schema. A list applies to every database in
BACKUP_DATABASES; a dict names tables per alias:
{"default": ["umami.*"]}. Tables a Django model owns are never matched,
as the fixture already holds them. A pattern that matches nothing is
logged as a warning at each backup.
Only the rows are saved, beside the fixture in
<name>.tables.gz: the app that made the tables keeps their structure
with its own migrations, so the tables must exist when you restore. On
PostgreSQL the rows are read and written with COPY on Django's own
connection, so every type comes back exactly; on other databases each row
is saved as JSON. The manifest lists each table with its columns and rows,
and the Backups page names them, with a link to download that file.
A restore empties the tables it loads, so include every table that points at one of them with a foreign key: PostgreSQL refuses to empty a table another table still points at. The rows are loaded parents first.
Next to each backup the app saves its manifest,
<name>.manifest.json: the Content Studio and Django versions, the database
engine, the applied migrations, the models left out and the number of rows
per model. A backup of
database default made on 20 November 2026 at 03:00 UTC is saved under the
time it started and a random token:
content_studio/backups/default/2026-11-20T030000Z-4f1c2a9e0b7d4e6a8c3f5b1d2e9a7c04.json.gz
content_studio/backups/default/2026-11-20T030000Z-4f1c2a9e0b7d4e6a8c3f5b1d2e9a7c04.manifest.json
The dump streams each table to a temporary file on the worker, which is
uploaded when it is done, so the worker needs free disk space for one
compressed backup. Every database in
BACKUP_DATABASES gets its own backup.
After each successful backup, older backups of that database beyond
BACKUP_KEEP are deleted, file and manifest,
and so are failed runs older than the oldest backup kept. A failed run
leaves no file behind.
On the status pageβ
With the status app installed, the page shows two rows:
- Database backups, a service. Operational while the latest backup is
newer than its scheduled time plus an hour. Degraded when a backup is
overdue or none has been made yet. Down when the last run failed, with its
error, or when the backup storage is missing. Not checked when
BACKUP_SCHEDULEisNoneand the last run did not fail. Its name links to the Backups page. - Back up the database, a recurring task, with the schedule in words, the latest run and the next. With Huey, this is Huey's periodic task, so it shows as one row.
The Backups pageβ
The Backups page lists the latest 100 backups, newest first, with the
database, what started it, its size, how long it took and the error of a
failed run. Download saves a backup's file. Back up now queues a
backup of every database in BACKUP_DATABASES as a Django task: with
Django's default ImmediateBackend it runs during the request, with a
background backend such as Huey it runs in a worker and the page shows it
running.
Only superusers see the page. Override has_backup_permission(request) on
your admin site (ADMIN_SITE) to decide
otherwise:
from content_studio.admin import ContentStudioSite
class BlogStudioSite(ContentStudioSite):
def has_backup_permission(self, request):
return request.user.groups.filter(name="Operations").exists()
Back up from the command lineβ
python manage.py content_studio_backup
python manage.py content_studio_backup --database default
python manage.py content_studio_backup --list
The command backs up the databases in BACKUP_DATABASES, or the ones you
pass with --database, and prunes the old ones like a scheduled backup. It
exits with an error when a backup fails, so cron can mail you. --list
prints the backups with their status, size and name.
Restore a backupβ
Restoring replaces everything in the database with the backup. Superusers restore on the Backups page, and anyone with a shell on the server can run the command.
On the Backups pageβ
Each finished backup has a Restore button, and the ⯠menu next to Back up now has Restore from a file⦠to upload one. Before anything changes, the dialog shows what the file holds: when it was made and with which versions, its rows per model, and whether its migrations match the database's. Then:
- Back up the current data first is on. The backup it makes shows up in the list as Before restore, so a restore can be undone.
- When the migrations differ, or the file has no manifest, you tick Restore anyway.
- A backup with extra tables lists them with their rows. They are emptied and loaded too, unless you tick Leave the extra tables as they are. A table that is gone, or that lacks some of the backup's columns, is marked: tick Restore anyway to leave it as it is and restore the rest. Columns added since the backup are fine: they get their default.
- You type the database's name (for SQLite, the file's name) and your password. Accounts without a password, such as single sign-on ones, are not asked for it.
- Replace database queues the restore as a Django task, like Back up now. The page shows it running, pauses backups until it is done, and reloads once the database holds the new data. Restores lists the latest ones with who started them and their error.
An uploaded file is saved in the backup storage under uploads/ and
deleted after the restore, or when you cancel. Uploads left behind are
deleted after a day. BACKUP_UPLOAD_MAX_SIZE
limits their size (1 GB by default). Only one restore or backup runs at a
time.
Override has_restore_permission(request) on your admin site to decide who
may restore. It defaults to has_backup_permission, so superusers:
class BlogStudioSite(ContentStudioSite):
def has_restore_permission(self, request):
return False # restore with the command only
From the command lineβ
python manage.py content_studio_restore --latest
python manage.py content_studio_restore content_studio/backups/default/2026-11-20T030000Z-4f1c2a9e0b7d4e6a8c3f5b1d2e9a7c04.json.gz
python manage.py content_studio_restore /tmp/2026-11-20T030000Z-4f1c2a9e0b7d4e6a8c3f5b1d2e9a7c04.json.gz --database default
python manage.py content_studio_restore /tmp/site.json.gz --ignore-migrations
Name a backup as --list prints it, or a file on disk (keep a backup's
manifest next to it). The command:
- Asks you to type the database's name.
--noinputskips the question. - Fetches the file and its manifest.
- Compares the backup's migrations with the database's. When they differ,
or there is no manifest, it stops: migrate the database to the backup's
state first, or pass
--ignore-migrations. - Backs up the current data, like Back up the current data first on
the page.
--no-safety-backupskips it. - Empties every table and loads the file, in one transaction, so a failed
load leaves the database as it was. The backup's extra tables are
emptied and loaded in the same transaction;
--skip-tablesleaves them as they are. An extra table that cannot be loaded stops the restore, or with--ignore-migrationsis left as it is.
The backup and restore records are kept as they are, so the Backups page still lists every backup after a restore.
Files made with dumpdataβ
Besides Content Studio's own backups, a restore takes any JSON fixture made
with manage.py dumpdata: .json, or compressed as .json.gz,
.json.bz2, .json.xz or .json.lzma.
python manage.py dumpdata --natural-foreign -o site.json.gz
Content types and permissions get new ids when the database is emptied, so
their rows in the file are left out and each reference to them by id is
matched by name instead. This works without --natural-foreign as long as
the file holds the content types and permissions it refers to. Sessions and
the backups app's own records are left out too. A file with models that are
not installed is refused. Such a file has no manifest, so its migrations
cannot be checked: restore it into a database migrated to the same state.
MySQL and MariaDB cannot roll back emptying a table. On those databases a failed restore leaves tables empty: restore into a fresh database, or keep the previous backup at hand.
To move a site to another database engine, migrate the new database, then restore a backup of the old one into it.
Settingsβ
| Setting | Default | |
|---|---|---|
BACKUP_STORAGE | "default" | The alias in STORAGES backups are saved in. |
BACKUP_FOLDER | "content_studio/backups" | The folder in that storage. |
BACKUP_SCHEDULE | "0 3 * * *" | When backups run, as a cron expression. |
BACKUP_KEEP | 14 | Backups kept per database. |
BACKUP_DATABASES | ["default"] | The databases backed up. |
BACKUP_EXCLUDE | [] | Apps and models left out. |
BACKUP_TABLES | None | Tables without a model to back up too. |
BACKUP_UPLOAD_MAX_SIZE | 1073741824 | The largest file you can upload to restore, in bytes. |
manage.py check reports settings that cannot work as
content_studio.E050, and a backup storage that may be public as
content_studio.E052.