To migrate your database from PostgreSQL to TimescaleDB, you
pg_dump for exporting your schema and data.
Migration falls into three main steps:
For this example we'll assume you have a PostgreSQL instance with a database
old_db that contains a single table called
conditions that you want to
convert into a hypertable in a new database called
Copying over your database schema is easily done with
pg_dump --schema-only -f old_db.bak old_db
This creates a backup file called
old_db.bak that contains only the
SQL commands to recreate all the tables in
old_db, which in this case
To create those tables in
psql -d new_db < old_db.bak
Now that we have the schema, we want to convert tables into hypertables where appropriate. So let's connect with the client:
psql -d new_db
Then use the
create_hypertable function on the tables to make hypertables.
Due to a current limitation, this must be run on a table while it is empty, so
we do this before importing data.
In this case, our hypertable target is
time as the time partitioning column):
SELECT create_hypertable('conditions', 'time');
Your new database is now ready for data.
To backup your data to CSV, we can run a
# The following ensures 'conditions' outputs to a comma-separated .csv file psql -d old_db -c "\COPY (SELECT * FROM conditions) TO old_db.csv DELIMITER ',' CSV"
Your data is now stored in a file called
Follow these instructions to insert data into your hypertable.
Now check out some common hypertable commands for exploring your data.
Found an issue on this page?Report an issue!