datamaker backup
Project description
Installation
pip install datamaker-backup
.env
.env.dist에 아래 내용 추가
# ENVIRONMENT
...
DEPLOYMENT_TARGET=development|test|production
# BACKUP
ENABLE_RESTORE=true|false
ENABLE_BACKUP=true|false
RESTORE_DATA_ONLY=true|false
RESTORE_OPTIONS=do-not-set-unless-you-know-what-you-are-doing
DBBACKUP_CLEANUP_KEEP=10
settings.py
settings.py에 아래 내용 추가
from datamaker_backup import get_backup_settings
...
INSTALLED_APPS = (
...
'dbbackup', # django-dbbackup
)
...
# datamaker-backup
# https://github.com/datamaker-kr/datamaker-backup
BACKUP_CONFIG = get_backup_settings('<repository-name>', env)
vars().update(BACKUP_CONFIG)
postgresql
PostgreSQL을 사용하는 프로젝트는 pg_dump, pg_restore로 백업 및 복원이 이루어지기 때문에 postgresql client 설치를 진행해야 합니다.
prepare to install latest postgresql
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt update
install postgresql client
sudo apt install postgresql-client
Usage
백업
database
python manage.py dbbackup
media
python manage.py mediabackup
복원
database
python manage.py dbrestore
media
python manage.py mediarestore
특정 백업으로 부터 복원하는 경우
python manage.py dbrestore -i <backup_id>
python manage.py mediarestore -i <backup_id>
Configuration
.env에서 아래 설정을 필요에 따라 적용.
DEPLOYMENT_TARGET
배포 환경 이름. 주로 development | test | production로 설정.
Required: true
ENABLE_RESTORE
true | false
dbrestore, mediarestore 사용 가능 여부. 주로 production 환경에서는 비활성화.
Default: false
ENABLE_BACKUP
true | false
dbbackup, mediabackup 사용 가능 여부. 주로 development 환경에서는 비활성화.
Default: false
RESTORE_DATA_ONLY
true | false
dbrestore시 schema는 그대로 두고 data만 복원할지 여부.
아직까지는 해당 옵션을 활성화 할 경우 복원할 db에 data가 모두 삭제된 상태로 두어야 함.
Default: false
RESTORE_OPTIONS
comma separated list of pg_restore option names
Example:
clean,create
Default:
RESTORE_DATA_ONLY가true일 때에는data-only,disable-triggers,exit-on-errorRESTORE_DATA_ONLY가false일 때에는clean,create,if-exists,exit-on-error
DBBACKUP_CLEANUP_KEEP
dbbackup시 지정된 숫자를 초과한 나머지 백업은 삭제됨.
Default: 30
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
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 datamaker-backup-0.2.0.tar.gz.
File metadata
- Download URL: datamaker-backup-0.2.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5daf2c6f534284ab59b820b8f0dc37018843796ec127aeceb31d02bfea968bf
|
|
| MD5 |
dd03aca66f3f0165d43db8d27babc53a
|
|
| BLAKE2b-256 |
a1675d4c94b0e31d9084ee4a965daa535846e2edd7a6a05451021c0996d8b5e4
|
File details
Details for the file datamaker_backup-0.2.0-py3-none-any.whl.
File metadata
- Download URL: datamaker_backup-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f2c397c36c881cb73f7018bb4bfd6ce6cdd2fe894fbaf3b57932c205735bc5
|
|
| MD5 |
036a3a4816677d8656a839dc0a8a3247
|
|
| BLAKE2b-256 |
7318e64c11464b89845067f126ece4acd0a80b59f42b4f67f491d76aa4f165be
|