Influxdb 2.0 - Moving database?

Bonjour ,

I’ve installed 2.0 new version on ubuntu server.
After testing i would like to move the data location to another disk and obviously the db

What i’m expecting to do :

  • Stopping influxdb during the operation.
sudo systemctl stop influxdb

Backing up db

sudo influx backup /media/hd-1TB/influxdb-sauvegarde_$(date '+%Y-%m-%d_%H-%M') -t token

Change data location in .toml file like this:
before :

cat config.toml 
bolt-path = "/home/airvb/.influxdbv2/influxd.bolt"
engine-path = "/home/airvb/.influxdbv2/engine"
storage-series-id-set-cache-size = 100

after :

cat config.toml 
bolt-path = "/media/influxdbv2/influxd.bolt"
engine-path = "/media/influxdbv2/engine"
storage-series-id-set-cache-size = 100

Restore db from previous backup

influx restore /media/hd-1TB/influxdb-sauvegarde_$(date '+%Y-%m-%d_%H-%M') -t token --full

Restart influxdb:

sudo systemctl start influxdb

What do you think about this method ?

Thanks

@airvb the influx backup and influx restore commands use the server’s API to download/upload data, so you’ll need to leave the server running to use them.

If you’re willing to stop the DB as part of the moving process, I’d instead recommend a simpler approach:

  1. Stop the DB
  2. Use cp or mv to relocate your /home/airvb/.influxdbv2 to /media/influxdbv2
  3. Edit your config file to point at the new location
  4. Start the DB
  5. Once you’ve verified things are working, delete the old directory (if you used cp instead of mv)

Is there a solution without stopping Influxdb ?

No, you’ll need to restart the DB at some point for the config-change to be picked up, and I don’t think it’s safe to cp the files from under a running DB since it bypasses in-process locks and the cache.

You could try backing up from your current server and restoring into a new instance, configured to store data at the new paths. The downside of this would be that you’ll miss out on any new data written after you’ve taken the backup.

Just to close the topic.
What did i do :
Stopping influxdb

sudo systemctl stop influxdb.service

Copy the data ( On ubuntu, default location of data is : /var/lib/influxdb )

sudo cp /var/lib/influxdb/ /media/hd-1TB/ -R

Change owner & group for --> influxdb: 

sudo chown influxdb:influxbd /media/hd-1TB/influxdb/ -R

Modify the configuration file ( location → /etc/influxdb/config.toml)

#bolt-path = "/var/lib/influxdb/influxd.bolt"
bolt-path = "/media/hd-1TB/influxdb/influxd.bolt"
#engine-path = "/var/lib/influxdb/engine"
engine-path = "/media/hd-1TB/influxdb/engine"

Start the influxdb service :

sudo systemctl start influxdb.service

Check datas arriving in the new folder :

airvb@airvb-serveur:/var/lib/influxdb$ sudo du -s /media/hd-1TB/influxdb/
**9153596**	/media/hd-1TB/influxdb/
airvb@airvb-serveur:/var/lib/influxdb$ sudo du -s /media/hd-1TB/influxdb/
**9153624**	/media/hd-1TB/influxdb/
airvb@airvb-serveur:/var/lib/influxdb$

Delete old folder
sudo rm /var/lib/influxdb/ -R

Thanks again for yr help.