Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: backup / restore #2

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ An init script is available with the following shortcut commands:

COMMANDS:

b | build build the docker images
c | cmd run a compose command
d | dev start a development server
i | init run initialization script
h | help prints this help text
m | manage run a wagtail manage.py command
s | shell run a django shell command with the app context
b | build build the docker images
backup | dump create a backup of the database
c | cmd run a compose command
d | dev start a development server
i | init run initialization script
h | help prints this help text
m | manage run a wagtail manage.py command
restore | load restore a database backup
s | shell run a django shell command with the app context
```
## Initial setup
After cloning this repository:
Expand Down
13 changes: 12 additions & 1 deletion ov
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ USAGE:\n\n

COMMANDS:\n\n

\t b | build \t build the docker images
\t b | build \t build the docker images \n
\t backup | dump \t create a backup of the database \n
\t c | cmd \t run a compose command \n
\t d | dev \t start a development server \n
\t i | init \t run initialization script \n
\t h | help \t prints this help text \n
\t m | manage \t run a wagtail manage.py command \n
\t restore | load\t restore a database backup \n
\t s | shell \t run a django shell command with the app context
"

Expand Down Expand Up @@ -59,6 +61,15 @@ elif [ $1 = "shell" -o $1 = "s" ]; then
shift
# docker run -it -v $(pwd)/:/app/ ov python3 manage.py shell "$@"
$COMPOSE_DEV $MANAGE shell "$@"
elif [ $1 = "dump" -o $1 = "backup" ]; then
shift
TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
$COMPOSE_DEV exec -it db pg_dump -Fc -U postgres postgres > db_$TIMESTAMP.sql

elif [ $1 = "load" -o $1 = "restore" ]; then
shift
# Restore a database from a dump file $1
$COMPOSE_DEV exec -iT db pg_restore --verbose --clean --no-acl --no-owner -U postgres -d postgres < $1

else echo -e $HELP

Expand Down
2 changes: 1 addition & 1 deletion ov_wag