File ownership for backup

I am on Influx Version: 1.7.4, Ubuntu 16.04

I am trying to use the command: influxd backup -portable influxdb_data_backup/

I am running this command from the terminal of ubuntu as my home user, “spvirt1”

I have the following file permission for the directory influxdb_data_backup/
spvirt1@spvirt1:/mnt/virt_drive$ ls -l
total 24
drwxrwxr-x 2 influxdb influxdb 4096 Apr 17 08:32 influxdb_data
drwxrwxr-x 2 influxdb influxdb 4096 Apr 17 08:33 influxdb_data_backup
drwx------ 2 root root 16384 Apr 17 00:07 lost+found

I am getting this error however:
spvirt1@spvirt1:/mnt/virt_drive$ influxd backup -portable influxdb_data_backup/
2019/04/17 09:09:18 backing up metastore to influxdb_data_backup/meta.00
backup: open temp file: open influxdb_data_backup/meta.00.pending: permission denied

Right now my data is all in the default directory and I was going to first back it up into this new folder and then switch the data directory from the default to my new “influxdb_data” folder. I appear to be having file permission problems. I don’t believe I should have to use sudo for this? Should I be running the command from within influxdb? I am just running it directly from the Ubuntu terminal.

Thanks for the help!

1 Like

Also, here is my ownership for /var/lib/influxdb. I believe it is correct as it shows influxdb as the owner.

spvirt1@spvirt1:/var/lib/influxdb$ ls -l
total 12
drwxr-xr-x 7 influxdb influxdb 4096 Feb 21 22:55 data
drwxr-xr-x 2 influxdb influxdb 4096 Apr 16 18:21 meta
drwx------ 7 influxdb influxdb 4096 Feb 21 22:55 wal
spvirt1@spvirt1:/var/lib/influxdb$

I guess I should add that I am trying to do this with influxdb still running, but as I understand that should not be a problem.

Also, my mount point is from an ext4 formatted drive I have auto mounted using fstab. I read a similar issue, here: Influx will not start if data directory changed - #2 by jeff
but I believe I already have my permission set correctly all the way back to the mount point:

spvirt1@spvirt1:/mnt$ ls -l
total 4
drwxrwxr-x 5 influxdb influxdb 4096 Apr 17 09:45 virt_drive

Hi @cuxcrider

backup and restore should be executed as the influxdb user ,
It is possible to run as another user though

Best regards

Hi Mark,
So you are saying instead of running the following command as my home user “spvirt1” I should run it as “influxdb”. Is there a default password, because I actually cannot switch to influxdb user without a password and I do not remember ever specifying one. Here is the command I run as the “spvirt1” user

influxd backup -portable influxdb_data_backup/

If you backup with another user , that user needs permissions on the backup location,
In your situation you could chmod 777 on the backup location to solve your permission problems or add your user to the Influxdb group …

In case you need to run with the Influxdb user you can use : sudo -u influxdb

Hi Mark,

Ok, I got it to work using: sudo -u influxdb influxd backup -portable influxdb_data_backup/

So, just to be clear then, when I run the command “influxd”, it is running as whatever user I am currently logged in as? It does not automagically switch to the “influxdb” user? Using sudo -u influxdb however should use influxdb as the user as you mentioned.

I am now about to try switching my data directory. As I mentioned above, all my ownership is “influxdb”, so I should be ok to change my config file, correct?

Thank you very much for the help

Haha, it worked!

I did the backup as we already covered. Then I modified the ‘meta’ and ‘data’ directories in my config file. I then restarted influxdb. I then used the restore command:

sudo -u influxdb influxd restore -portable influxdb_data_backup/

it put everything into my newly created data directory. My devices appear to be logging correctly and even Chronograf appears perfectly happy.

Thanks again!!

Good to hear it is working :slight_smile: