A Django app to easily backup your sqlite database through an endpoint.
Project description
Django Sqlite Backup
A Django application to backup you SQLite database by calling and endpoint.
Installation
From PYPi using pip:
pip install django-sqlite-backup
Usage
Add the app to the INSTALLED_APPS:
INSTALLED_APPS = [
...,
"django_sqlite_backup",
...,
]
Then, add the app's URLs to the root URL conf:
path("", include("django_sqlite_backup.urls")),
This will create a route in your application to backup your sqlite database:
GET /backup/
204: Successful backup
Write your own view
If you want to use a different method or want to add some sort of authentication or other kinds of logic with the backup call, you can write your own view importing the do_backup function:
# views.py
from django.http import HttpRequest
from django.http import JsonResponse
from django_sqlite_backup import backup
def my_view(request: HttpRequest) -> JsonResponse:
do_backup()
return JsonResponse({}, status=204)
Settings
You must define your settings in your settings.py:
SQLITE_BACKUP = {
"BACKUP_CLASS": ...,
"RESTORE_CLASS": ...,
"BUCKET_NAME": ...,
"S3_ENDPOINT": ...,
}
BACKUP_CLASSmust point to class which follows theSqliteBackupprotocol.RESTORE_CLASSmust point to class which follows theSqliteRestoreprotocol.BUCKET_NAMEis the name of the bucket in S3 which can be written to.S3_ENDPOINTS3 endpoint override. Leave this blank if you use AWS S3 directly.
Management commands
This app provides two commands for carrying out operations on the backups: backup and restore.
./manage.py backup
Will back up the current sqlite database into the configured bucket.
./manage.py restore [date_str]
Will restore your sqlite database from your configured bucket on the date specified.
The date_str is optional and defaults to today.
AWS
By default, the backup class uses boto3 to backup the sqlite database into S3. Therefore, you will need to also pass the AWS Environment Variables to the environment where your application is running.
Licence
This package is distributed under MIT Licence.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_sqlite_backup-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_sqlite_backup-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7955750740ec994fa7b9e07a21ebdf899a9c0f9e022d48c8b2d409292678e81
|
|
| MD5 |
707f9f7651783880153134b72736c107
|
|
| BLAKE2b-256 |
ee23c8c22ad7af0af9ed583f122868e30e23e92e07e0f115a2ec4d03270aaa67
|