Changes
Page history
Update Create a DB dump
authored
Oct 11, 2019
by
Daniel Palomar
Show whitespace changes
Inline
Side-by-side
Create-a-DB-dump.md
View page @
3ae86a4c
...
@@ -14,55 +14,8 @@ $ ssh opencell-test.coopdevs.org
...
@@ -14,55 +14,8 @@ $ ssh opencell-test.coopdevs.org
$ sudo su - opencell
$ sudo su - opencell
```
```
3.
Access to the db container
:
3.
Create the dump
:
```
```
$ docker exec -ti postgres bash
$ docker exec "postgres" pg_dump -U "opencell" --encoding=UTF8 "opencell" > "opencell_$(date +"%d-%m-%y").sql"
```
4.
Create the dump:
```
# pg_dump -U opencell -W -f opencell.19.08.07.dump opencell
```
> If you don't know the db user and password, you can check it in the `docker-compose.yml` file with the keys: `DB_USER` and `DB_PASSWORD`.
5.
Exit and copy the dump out of the container:
```
# exit
exit
$ docker cp postgres:/opencell.19.08.07.dump .
```
6.
Move the dump to your user home and change the permissions:
```
$ exit
logout
daniel@opencell-test:~$ sudo chown daniel:daniel /home/opencell/opencell.19.08.07.dump
daniel@opencell-test:~$ sudo mv /home/opencell/opencell.19.08.07.dump .
```
7.
Copy the dump form the server to your machine:
```
$ logout
Connection to opencell-test.coopdevs.org closed.
$ scp opencell-test.coopdevs.org:opencell.19.08.07.dump .
opencell.19.08.07.dump 100% 1027KB 2.5MB/s 00:00
```
And you have the dump in your local machine!
--------------------------
### UPDATE
In the backups script we use the next command to generate the dump out of the container:
```
$ docker exec "postgres" pg_dump -U "${DATABASE_USER}" --encoding=UTF8 "${DATABASE_NAME}" > "/opt/backup/.tmp/pg_dump_${DATABASE_NAME}.sql"
```
```
\ No newline at end of file