Restore only Xi users?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
DFaught
Posts: 62
Joined: Tue Sep 26, 2017 12:50 pm

Restore only Xi users?

Post 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.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Restore only Xi users?

Post 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
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Restore only Xi users?

Post 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
DFaught
Posts: 62
Joined: Tue Sep 26, 2017 12:50 pm

Re: Restore only Xi users?

Post 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
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Restore only Xi users?

Post 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
DFaught
Posts: 62
Joined: Tue Sep 26, 2017 12:50 pm

Re: Restore only Xi users?

Post by DFaught »

Thank you very much, This will work.
Happy Holidays!
Regards,
Dave
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Restore only Xi users?

Post by pbroste »

Excellent Dave, have a Happy New Year, I will go ahead and lock.

Thanks,
Perry
Locked