Until there’s a command specifically for renaming a database, what steps should I take to do this manually?
Hi Jeff… great question.
You might think that doing something like this:
SELECT * INTO <my_newDB> FROM <my_oldDB>
might do the trick. However, that does NOT maintain the series context for the tags. This means that tags will be stored as fields in the destination database ( <my_newDB>
in this example). In order to maintain series context, you need to run the command like this:
SELECT *
INTO <my_newDB>.<RP>.<MEASUREMENT>
FROM <my_oldDB>.<RP>.<MEASUREMENT>
GROUP BY *
in order to keep the tag values stored as tags.
When moving large measurements around with similar queries, we also HIGHLY recommendation to run those queries sequentially using time boundaries (where time > … and time < … ) in order to avoid running out of memory.
There is more info in the documentation here: Data Exploration | InfluxData Documentation Archive
Hope this helps!
So something like this? I assume inserting dupes is ok (I made the inserts go up so that the time slices would overlap by the duration of the call so I wouldn’t lose data.)
CREATE DATABASE {DEST_DB};
CREATE RETENTION POLICY {MEASUREMENT} on {DEST_DB} DURATION {SRC_DB_RP_DURACTION} REPLICATION {SRC_DB_RP_DURACTION} DEFAULT
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 100w and time < now() - 90w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 90w and time < now() - 80w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 80w and time < now() - 70w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 70w and time < now() - 60w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 60w and time < now() - 50w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 50w and time < now() - 40w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 40w and time < now() - 30w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 30w and time < now() - 20w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 20w and time < now() - 10w GROUP BY *
SELECT * INTO {DEST_DB}.{MEASUREMENT}.{MEASUREMENT} FROM {SRC_DB}.{SRC_DB}_rp.{MEASUREMENT} WHERE time > now() - 10w and time < now() GROUP BY *
Yes. The duplicates will simply be overwritten.
Hi everybody , @sbengo and myself have released an easy of use tool which can help on these kind of data operations (move, rename, synchronization) , not only in the same machine, could also work over diferent influxdb instances.
Right now working only with influxdb 1.X.
any feedback would be greatly appreciated