Created
September 9, 2025 13:05
-
-
Save pizzaboxer/f52ce119902cb07e1e9a18ba57c22cf6 to your computer and use it in GitHub Desktop.
Migrate specific InfluxDBv2 buckets of one org from one server to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # InfluxDBv2 migration script | |
| # Copies specific chosen buckets of one org from one server to another | |
| # Guidance: | |
| # Run this script on a machine running the server with the source data | |
| # | |
| # The Influx CLI ('influx') must be configured with an active | |
| # profile for the remote server. Operator perms are ideal; | |
| # without then you'll need to create the buckets manually | |
| # | |
| # Manually configure retention policy on new server after migration | |
| # | |
| # Running this script multiple times will simply append any new data that | |
| # exists (errors about creating existing buckets can be ignored) | |
| # Source buckets must be configured with bucketname;bucketid | |
| buckets=('bucket1;1ed3c2bdf95bd08f' \ | |
| 'bucket2;710d77fe74c18910' \ | |
| ) | |
| for bucket in ${buckets[@]}; do | |
| IFS=';' read -a data <<< $bucket | |
| bucketname=${data[0]} | |
| bucketid=${data[1]} | |
| echo [!] Exporting $bucketname | |
| influxd inspect export-lp \ | |
| --bucket-id $bucketid \ | |
| --engine-path /var/lib/influxdb2/engine \ | |
| --output-path $bucketname.lp \ | |
| --start 2005-01-01T00:00:00Z \ | |
| --end 2030-01-01T00:00:00Z \ | |
| --compress | |
| echo [!] Writing $bucketname... | |
| influx bucket create -n $bucketname | |
| influx write --format lp \ | |
| --bucket $bucketname \ | |
| --file $bucketname.lp \ | |
| --compression gzip | |
| echo [!] Done migrating $bucketname. | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment