Skip to main content

Django app to backup Sqlite or Postgres database to an S3 Object Storage.

Project description

Telescoop Backup

Backup your sqlite database to an S3 compatible provider.

Quick start

Configuration

  • Add "Telescop Backup" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
    ...
    'telescoop_backup',
]
  • Include the Telescop Backup URLconf in your project urls.py like this::
    path('backup/', include('telescoop_backup.urls')),
  • Define the following settings in settings.py
BACKUP_ACCESS = 'my_access'  # S3 ACCESS
BACKUP_SECRET = 'my_secret'  # S3 SECRET KEY
BACKUP_BUCKET = 'my_project_backup'  # S3 Bucket
BACKUP_KEEP_N_DAYS = 31  # Optional, defaults to 31
BACKUP_HOST = None  # Optional, default to s3.fr-par.scw.cloud (Scaleway Storage in Paris)
BACKUP_USE_AWS = False # True if you want to use Amazon s3
BACKUP_REGION = 'eu-west-1' # only used when BACKUP_USE_AWS is True

# Optional, for compressing the backup
BACKUP_COMPRESS = True
BACKUP_RECOVER_N_WORKERS = 4  # Optional, default to 1

# Optional, security backup settings - for duplicating files to a second location
SECURITY_BACKUP_PATH_LIST = ['/path/to/media']  # List of paths to backup
SECURITY_BACKUP_BUCKET = 'my_project_security_backup'  # Destination bucket
SECURITY_BACKUP_DESTINATION = 'security_backup'  # Optional, prefix in destination bucket
SECURITY_BACKUP_HOST = 's3.fr-par.scw.cloud'  # Optional, defaults to BACKUP_HOST
SECURITY_BACKUP_REGION = 'fr-par'  # Optional, defaults to BACKUP_REGION
BACKUP_MAX_PAGINATION_ITERATIONS = 10000  # Optional, safety limit for S3 pagination

By default, old backups are removed in order not to take up too much space. If you don't want them removed, just set a very large value for BACKUP_KEEP_N_DAYS.

Backup

You can now backup with the backup_db management command :

  • python manage.py backup_db backup to back up current database
  • python manage.py backup_db backup_media to back up settings.MEDIA_ROOT
  • python manage.py backup_db list to list previous backups
  • python manage.py backup_db recover [file_name] to recover previous database

View last backup and if it is recent

  • /backup/last-backup shows the latest backup
  • /backup/backup-is-less-than-XX-hours-old answers yes (status 200) or no (status 500). This route can be used with a service such as uptimerobot.com.

Security Backup

This solution duplicates media files currently stored directly on S3, providing a backup in case of accidental deletion (for example, due to a misconfigured Ansible script). This is designed to mitigate this specific risk, as Scaleway already provides data redundancy (3 copies by default, even in case of hardware failure).

Gitignore

If you use it in local environment, ignore the backup files

.telescoop_backup_last_backup
*.sqlite

Development

  • Update version in setup.cfg ;
  • Create a tag for PyPI publishing ;

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telescoop_backup-0.6.4.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telescoop_backup-0.6.4-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file telescoop_backup-0.6.4.tar.gz.

File metadata

  • Download URL: telescoop_backup-0.6.4.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for telescoop_backup-0.6.4.tar.gz
Algorithm Hash digest
SHA256 0df01932742570beb5f15d4be8325a08c78fd285eea1f50ddcc44b7b7207381f
MD5 fb08144bb9a2cd949fc1f649ccba61e7
BLAKE2b-256 cab14ecfd01a6aaad8734c332237a218a368d53b4c49478928528e3037c50511

See more details on using hashes here.

File details

Details for the file telescoop_backup-0.6.4-py3-none-any.whl.

File metadata

File hashes

Hashes for telescoop_backup-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c30e2f001d5d9fba3d844ae05f150d0e96cc2c6ecc0b8550eae4410a7c57c869
MD5 7bd72e4ab4eaeb71727d94e9eda91641
BLAKE2b-256 d5a68e4130cca873dbc84c2811379da193b5153feea3a35f7b7c0a41a24edfcf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page