slzdevsnp
11/21/2019 - 2:28 PM

[timescaledb] #db #sql #timescaledb #postgres

[timescaledb] #db #sql #timescaledb #postgres

from https://docs.timescale.com/latest/using-timescaledb/backup#

backup a db named tutorial

pg_dump -Fc -f /path_to_dumps/tutorial.bak tutorial

restoration

sudo -u postgres psql

Once connected to psql :

CREATE DATABASE tutorial;
\c tutorial --connect to the db where we'll perform the restore
CREATE EXTENSION timescaledb;
SELECT timescaledb_pre_restore();

-- execute the restore (or from a shell)
\! pg_restore -Fc -d tutorial tutorial.bak


SELECT timescaledb_post_restore();

pull and run image with 2 mounted folders

docker run -d --name timescaledb \
-p 5432:5432 \
-e POSTGRES_PASSWORD=postgres \
-v /Users/zimine/sdata/docker-shared/timescaledb/postgresql/data:/var/lib/postgresql/data \
-v /Users/zimine/sdata/docker-shared/timescaledb/postgresql/dumps:/opt/dumps \
timescale/timescaledb:latest-pg11

It takes some time to start postgres server, but it starts

NB: for updates do docker pull timescale/timescaledb:latest-pg11

connect to bash docker exec -it timescaledb bash

connect to psql docker exec -it timescaledb psql -U postgres