Add Django dbbackup

https://github.com/django-dbbackup/django-dbbackup

* use postgres v11 (because only this version exists in debian buster, too)
* update to python v3.9 in compose usage
pull/8/head
JensDiemer 2020-10-24 16:34:33 +02:00
rodzic 26e3e5f803
commit 27f99d21e5
9 zmienionych plików z 52 dodań i 5 usunięć

4
.gitignore vendored
Wyświetl plik

@ -8,6 +8,10 @@
!/.style.yapf !/.style.yapf
!.coveralls.yml !.coveralls.yml
# for django-dbbackup
/backups/
!/backups/.gitkeep
# from test projects: # from test projects:
/static/ /static/
/media/ /media/

Wyświetl plik

@ -1,9 +1,10 @@
FROM python:3.7-slim-buster FROM python:3.9-slim-buster
# https://hub.docker.com/_/python
# Install deps # Install deps
RUN apt-get update \ RUN apt-get update \
&& apt-mark auto $(apt-mark showinstall) \ && apt-mark auto $(apt-mark showinstall) \
&& apt-get install -y python3-pip \ && apt-get install -y postgresql-client-11 python3-pip \
&& apt autoremove \ && apt autoremove \
&& apt -y full-upgrade \ && apt -y full-upgrade \
&& rm -rf /var/lib/apt \ && rm -rf /var/lib/apt \

Wyświetl plik

@ -146,6 +146,20 @@ logs_inventory: ## Display docker logs from postgres container
############################################################################## ##############################################################################
dbbackup: ## Backup database
./manage.sh dbbackup
docker_dbbackup: ## Backup database (Docker usage)
./compose.sh exec inventory ./manage.sh dbbackup
dbrestore: ## Restore a database backup
./manage.sh dbrestore
docker_dbrestore: ## Restore a database backup (Docker usage)
./compose.sh exec inventory ./manage.sh dbrestore
##############################################################################
restart: down up ## Restart all containers restart: down up ## Restart all containers
upgrade_inventory: ## Upgrade "inventory" container and restart it upgrade_inventory: ## Upgrade "inventory" container and restart it

Wyświetl plik

@ -76,6 +76,8 @@ down Stop all containers
prune Cleanup docker prune Cleanup docker
build Update docker container build build Update docker container build
logs Display docker logs from all containers logs Display docker logs from all containers
dbbackup Backup database
dbrestore Restore a database backup
restart Restart all containers restart Restart all containers
}}} }}}

Wyświetl plik

@ -113,6 +113,8 @@ prepare
prune Cleanup docker prune Cleanup docker
build Update docker container build build Update docker container build
logs Display docker logs from all containers logs Display docker logs from all containers
dbbackup Backup database
dbrestore Restore a database backup
restart Restart all containers restart Restart all containers
.env .env
@ -244,4 +246,4 @@ donation
------------ ------------
``Note: this file is generated from README.creole 2020-10-24 14:31:12 with "python-creole"`` ``Note: this file is generated from README.creole 2020-10-24 16:39:24 with "python-creole"``

Wyświetl plik

@ -25,7 +25,7 @@ services:
postgres: postgres:
# https://hub.docker.com/_/postgres # https://hub.docker.com/_/postgres
image: postgres:13-alpine image: postgres:11-alpine
restart: "no" restart: "no"
hostname: postgres hostname: postgres
ports: ports:

Wyświetl plik

@ -39,6 +39,7 @@ INSTALLED_APPS = [
'bx_py_utils', # https://github.com/boxine/bx_py_utils 'bx_py_utils', # https://github.com/boxine/bx_py_utils
'import_export', # https://github.com/django-import-export/django-import-export 'import_export', # https://github.com/django-import-export/django-import-export
'dbbackup', # https://github.com/django-dbbackup/django-dbbackup
'ckeditor', # https://github.com/django-ckeditor/django-ckeditor 'ckeditor', # https://github.com/django-ckeditor/django-ckeditor
'reversion', # https://github.com/etianen/django-reversion 'reversion', # https://github.com/etianen/django-reversion
'reversion_compare', # https://github.com/jedie/django-reversion-compare 'reversion_compare', # https://github.com/jedie/django-reversion-compare
@ -142,6 +143,12 @@ STATIC_ROOT = str(__Path(BASE_PATH, 'static'))
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = str(__Path(BASE_PATH, 'media')) MEDIA_ROOT = str(__Path(BASE_PATH, 'media'))
# _____________________________________________________________________________
# Django-dbbackup
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
DBBACKUP_STORAGE_OPTIONS = {'location': str(__Path(BASE_PATH, 'backups'))}
# _____________________________________________________________________________ # _____________________________________________________________________________
# Django-Debug-Toolbar # Django-Debug-Toolbar

18
poetry.lock wygenerowano
Wyświetl plik

@ -258,6 +258,19 @@ python-versions = "*"
[package.dependencies] [package.dependencies]
django-js-asset = ">=1.2.2" django-js-asset = ">=1.2.2"
[[package]]
name = "django-dbbackup"
version = "3.3.0"
description = "Management commands to help backup and restore a project database and media"
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
Django = ">=1.5"
pytz = "*"
six = "*"
[[package]] [[package]]
name = "django-debug-toolbar" name = "django-debug-toolbar"
version = "3.1.1" version = "3.1.1"
@ -1178,7 +1191,7 @@ postgres = ["psycopg2-binary"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = ">=3.7,<4.0.0" python-versions = ">=3.7,<4.0.0"
content-hash = "4ad32caba18b4f973eee3d59a129b1ccd5750289a60c07939e1ab2f973fb4940" content-hash = "d07f05b3cb200bb30974923869838af5e96a1935fdcbaa2e536f03f046583d90"
[metadata.files] [metadata.files]
appdirs = [ appdirs = [
@ -1365,6 +1378,9 @@ django-ckeditor = [
{file = "django-ckeditor-6.0.0.tar.gz", hash = "sha256:29fd1a333cb9741ac2c3fd4e427a5c00115ed33a2389716a09af7656022dcdde"}, {file = "django-ckeditor-6.0.0.tar.gz", hash = "sha256:29fd1a333cb9741ac2c3fd4e427a5c00115ed33a2389716a09af7656022dcdde"},
{file = "django_ckeditor-6.0.0-py2.py3-none-any.whl", hash = "sha256:cc2d377f1bdcd4ca1540caeebe85f7e2cd006198d57328ef6c718d3eaa5a0846"}, {file = "django_ckeditor-6.0.0-py2.py3-none-any.whl", hash = "sha256:cc2d377f1bdcd4ca1540caeebe85f7e2cd006198d57328ef6c718d3eaa5a0846"},
] ]
django-dbbackup = [
{file = "django-dbbackup-3.3.0.tar.gz", hash = "sha256:bb109735cae98b64ad084e5b461b7aca2d7b39992f10c9ed9435e3ebb6fb76c8"},
]
django-debug-toolbar = [ django-debug-toolbar = [
{file = "django-debug-toolbar-3.1.1.tar.gz", hash = "sha256:c97921a9cd421d392e7860dc4b464db8e06c8628df4dc58fedab012888c293c6"}, {file = "django-debug-toolbar-3.1.1.tar.gz", hash = "sha256:c97921a9cd421d392e7860dc4b464db8e06c8628df4dc58fedab012888c293c6"},
{file = "django_debug_toolbar-3.1.1-py3-none-any.whl", hash = "sha256:a1ce0665f7ef47d27b8df4b5d1058748e1f08500a01421a30d35164f38aaaf4c"}, {file = "django_debug_toolbar-3.1.1-py3-none-any.whl", hash = "sha256:a1ce0665f7ef47d27b8df4b5d1058748e1f08500a01421a30d35164f38aaaf4c"},

Wyświetl plik

@ -45,6 +45,7 @@ gunicorn = "*" # https://gunicorn.org/
django = "2.2.*" django = "2.2.*"
django-debug-toolbar = "*" # http://django-debug-toolbar.readthedocs.io/en/stable/changes.html django-debug-toolbar = "*" # http://django-debug-toolbar.readthedocs.io/en/stable/changes.html
django-import-export = "*" # https://github.com/django-import-export/django-import-export django-import-export = "*" # https://github.com/django-import-export/django-import-export
django-dbbackup = "*" # https://github.com/django-dbbackup/django-dbbackup
django-tools = "*" # https://github.com/jedie/django-tools/ django-tools = "*" # https://github.com/jedie/django-tools/
django-reversion-compare = "*" # https://github.com/jedie/django-reversion-compare/ django-reversion-compare = "*" # https://github.com/jedie/django-reversion-compare/
django-ckeditor = "*" # https://github.com/django-ckeditor/django-ckeditor django-ckeditor = "*" # https://github.com/django-ckeditor/django-ckeditor