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.

Thanks for this. Followed your process successfully on a Raspberry Pi influxdb after wasting too much time on search results for moving v1.x influxdb databases.

The only small hitch was the systemd scripts in /usr/lib/influxdb/scripts. They want to see a .PID file in the /var/lib/influxdb folder. I guess that I could edit the script but I was lazy so just left an empty /var/lib/influxdb for the scripts to use

Hallo ich hab es jetzt Stundenlang versucht aber es scheitert an der Rechtevergabe :
sudo chown root:influxbd /media/hd-1TB/influxdb/ -R

Die Ordner der externen Festplatte gehören alle root. Ich bekomme immer den Fehler falsche

...@raspberrypi:~ $ ls -al /media/ext_festplatte/InfluxDB/
insgesamt 768
drwxrwxrwx  3 root root 262144  6. Nov 15:36 .
drwxrwxrwx 13 root root 262144  6. Nov 15:34 ..
drwxrwxrwx  4 root root 262144  6. Nov 15:37 influxdb

Entweder keine Berechtigung, Operation nicht erlaubt oder Gruppe existiert nicht. Hat jemand eine Idee ?

Hello , in english pls,

Which command to change owner/group ?

it should be:

sudo chown influxdb:influxdb /media/ext_festplatte/InfluxDB/ -R

I tried this using sshfs. First rsynced the entire influxdb to my remote server. After that I mounted that folder back like so:

sshfs -o default_permissions,uid=116,gid=123 influxdb@remote.server.ip:/media/influxdb /var/lib/influxdb

uid 116 and 123 is the uid and gid of influxdb on the local machine. One would expect this would work but no.

Jul 25 15:50:46 orangepi3-lts systemd[1]: influxdb.service: Scheduled restart job, restart counter is at 4.
Jul 25 15:50:46 orangepi3-lts systemd[1]: Stopped InfluxDB is an open-source, distributed, time series database.
Jul 25 15:50:46 orangepi3-lts systemd[1]: Starting InfluxDB is an open-source, distributed, time series database...
Jul 25 15:50:46 orangepi3-lts influxd-systemd-start.sh[142549]: /usr/lib/influxdb/scripts/influxd-systemd-start.sh: line 5: /var/lib/influxdb/influxd.pid: Permission denied
Jul 25 15:50:46 orangepi3-lts systemd[1]: influxdb.service: Control process exited, code=exited, status=1/FAILURE
Jul 25 15:50:46 orangepi3-lts systemd[1]: influxdb.service: Failed with result 'exit-code'.