Backs up django postgres databases, local folders and S3 folders to a Google Drive folder through a google service account.
Project description
django-gdrive-backup
Backs up django postgres databases, local folders and S3 folders to a Google Drive folder through a google service account.
Create service account
Requires a Google service account with the Google Drive API enabled
https://console.cloud.google.com/apis/credentials/serviceaccountkey
Store service account key
By default encrypted-credentials is used to store the key. Create a directory off the django projects BASE_DIR called credentials and save the json key.
settings.py
CREDENTIAL_FOLDER = os.path.join(BASE_DIR, 'credentials')
CREDENTIAL_FILES = {
'drive': 'service-account.json',
}
Create Google Drive folder and share with service account
With a Google Drive account create a folder and share with the email address of the service account.
Configure database backup
settings.py
BACKUP_GDRIVE_DIR = 'django_backup'
BACKUP_GDRIVE_DB = BACKUP_GDRIVE_DIR + '/db'
Management commands
python manage.py backup_website
python manage.py restore_db
Management page
urls.py
urlpatterns = [
path('backup/', include('gdrive_backup.urls')),
....
Configure S3 folder backups
settings.py
AWS_ACCESS_KEY_ID = id
AWS_SECRET_ACCESS_KEY = key
AWS_PRIVATE_STORAGE_BUCKET_NAME = bucket
S3_BACKUP_DIRS = [('S3-source-folder1', 'google-drive-folder1'),
('S3-source-folder2', 'google-drive-folder2')
]
Configure cleaning of old datatabase backups
settings.py
BACKUP_DB_RETENTION = [{'hours': 1, 'number': 4},
{'hours': 2, 'number': 10},
{'days': 1, 'number': 10},
{'months': 1, 'number': 36},
]
Schedule backup with celery beat
CELERY_BEAT_SCHEDULE = {
'backup': {
'task': 'gdrive_backup.tasks.backup',
'schedule': crontab(hour='8-19', minute=10, day_of_week='mon-fri')
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-gdrive-backup-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c54a23758e0b626eafe7c3b52630710a0fb0f987afc15c36790f5f28c123bd07 |
|
MD5 | c1693ccddb8d45af16fed4589b99fbb5 |
|
BLAKE2b-256 | cd27412f188d40baa1e7f35ba5667f739c309afc55e53e32b6953475f5eedc30 |
Hashes for django_gdrive_backup-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29bbd9c3eca82a9ef35177193c0226a13a49e5c741222a9b74f156668ca99bb3 |
|
MD5 | 77808e3625e9f93cd88dfd93bf6154bd |
|
BLAKE2b-256 | 11f38a42f06392c45f6a41e7ed6870eac99823343adb020c0e7bb1270a6a8783 |