Pytigon applications store data in multiple places — the database, uploaded files, configuration. A comprehensive backup strategy covers all of them.
| Component | Location | Method |
|---|---|---|
| Database (SQLite) | [DATA]/[PRJ]/[PRJ].db |
Copy the file (while server is stopped) |
| Database (PostgreSQL/MySQL) | External database server | pg_dump / mysqldump |
| Uploaded files | VFS storage (disk or DB) | Copy VFS root directory |
| Project source code | [PRJ]/ |
Git repository (recommended) |
| Configuration | settings_app.py |
Git repository |
| PIP-installed libs | [DATA]/[PRJ]/prjlib/ |
Included in file backup |
| Compiled extensions | [DATA]/[PRJ]/syslib/ |
Rebuild from source |
SQLite databases are single files — backup is a file copy:
# Stop the application
ptig run stop
# Copy the database
cp [DATA]/[PRJ]/[PRJ].db /backup/[PRJ]_$(date +%Y%m%d).db
# Restart the application
ptig run
For zero-downtime backup, use SQLite's .backup command through sqlite3 CLI or a background task that calls VACUUM INTO.
pg_dump -h localhost -U pytigon_user pytigon_db > /backup/pytigon_$(date +%Y%m%d).sql
Pytigon's task scheduler can automate backups:
async def nightly_backup(cmd):
cmd("dbbackup")
cmd("mediabackup")
def init_schedule(scheduler, cmd, http):
scheduler.add_task("daily(at='03:00')", nightly_backup, cmd)
python manage.py migrate)Regularly verify backups by restoring to a test environment. A backup you haven't tested is a backup you don't have.