Page 1 of 1

Restore only Xi users?

Posted: Tue Dec 28, 2021 11:21 am
by DFaught
Is there a way to restore only the Nagios XI users? I was trying to clean up some old user entries and cleaned up a several too many. The rest of the server is fine.

Re: Restore only Xi users?

Posted: Tue Dec 28, 2021 1:05 pm
by gsmith
Hi

When was the last time you did a backup?

Looks like you sent us a System Profile around December 8 for ticket https://support.nagios.com/tickets/scp/ ... p?id=16789
If that is current enough I could send you the mysqldumps from it.

Let me know.

Thanks

Re: Restore only Xi users?

Posted: Tue Dec 28, 2021 1:09 pm
by pbroste
Hello @DFaught

Thanks for reaching out, there are several ways you could go about going through your User Accounts, and want to go over 'api' method:

Code: Select all

https://yourhostaddresshere/nagiosxi/help/api-system-reference.php#user
To get a list:

Code: Select all

curl -XGET "https://192.168.23.200/nagiosxi/api/v1/system/user?apikey=yourapikeyhere&pretty=1"
or without 'pretty' for easier formating for adding new:

Code: Select all

curl -XGET "https://192.168.23.200/nagiosxi/api/v1/system/user?apikey=yourapikeyhere"
Once you have a list you can delete the User account based on 'user_id'. If you want you could automate this with a script:

Code: Select all

curl -XDELETE "https://192.168.23.200/nagiosxi/api/v1/system/user/XX?apikey=yourapikeyhere&pretty=1"
* XX=user_id#

Thanks,
Perry

Re: Restore only Xi users?

Posted: Tue Dec 28, 2021 1:19 pm
by DFaught
I have between 20 and 40 or so users each on 10 different NagiosXI servers that I need to get back.
@pbroste, this is what got me into trouble in the first place. I'm trying to recover now.
@gsmith, I have backups from each server from a couple days ago. The question is - is there a way to get all the users back without having to restore everything?

Thank you for your responses.

Dave

Re: Restore only Xi users?

Posted: Tue Dec 28, 2021 4:06 pm
by pbroste
Hello @DFaught

Thanks for following up and providing further details.

You can take your compressed backup and extract: tar -xvf 16xxxxxxxx.tar.gz

In the directory path: 16xxxxxxxxx/mysql will find the individual databases:
  • In nagiosql --> tbl_user is the schema, not much to see there
  • In nagiosxi --> xi_users is the user data that you will be interested in
I am using a script that is highly recommended and easily found:

Code: Select all

./mysqldumpsplitter.sh --source /tmp/16xxxxxxxx/mysql/nagiosxi.sql --extract TABLE --match_str xi_users --compression none
To review the table output to verify:

Code: Select all

cat out/xi_users.sql
Looks good then import:

Code: Select all

mysql -uroot -p -D nagiosxi < whicheverdirectory/xi_users.sql
I am providing one way of working your way through export/import, but there are many other alternatives that will work. Please use what you are comfortable with. Very important to make a backup before importing to the database just in case something goes wonky.

Thanks
Perry

Re: Restore only Xi users?

Posted: Wed Dec 29, 2021 8:19 am
by DFaught
Thank you very much, This will work.
Happy Holidays!
Regards,
Dave

Re: Restore only Xi users?

Posted: Wed Dec 29, 2021 10:15 am
by pbroste
Excellent Dave, have a Happy New Year, I will go ahead and lock.

Thanks,
Perry