Page 1 of 1

Lost Dashboards/Reports After User Account Recreated

Posted: Wed Mar 03, 2021 5:06 pm
by silverbenz
Hi,

Our customer recently advised they were shifting our user accounts to a new Active Directory domain. As a result all of our accounts were re-imported from the new AD. I've now discovered all of my custom dashboards and reports have disappeared. I'm assuming this is because my account was effectively deleted and recreated.

There was a fair bit of work in these dashboards and reports, so I was hoping there might be some way for me to get them back from a backup (or similar) without having to do a full restore? Maybe some way to extract them from a database and associate them to my current user account?

Thanks in hope,
Ben.

Re: Lost Dashboards/Reports After User Account Recreated

Posted: Thu Mar 04, 2021 6:22 pm
by ssax
Unfortunately, there's not currently a process to do this.

Take an XI backup first in case you make a mistake so you can restore it.

You would need to extract the backup file and then go into the mysql directory in the extracted backup and work on the nagiosxi.sql file.

Create a new file and put ONLY the xi_users and xi_usermeta (only add the create table AND the data insert sections from the nagiosxi.sql file for both the xi_users and xi_usermeta table), then replace all occurrences of xi_users with xi_usersold AND replace all occurrences of xi_usermeta with xi_usermetaold in that new file.

Then import the data:

Code: Select all

mysql -uroot -pnagiosxi nagiosxi <  yournewfile.sql
Then find your OLD user_id and make a note of it:
- Change yourusername

Code: Select all

mysql -uroot -pnagiosxi nagiosxi -e "select user_id from xi_usersold where username = 'yourusername';"
Then find your NEW user_id and make a note of it:
- Change yourusername

Code: Select all

mysql -uroot -pnagiosxi nagiosxi -e "select user_id from xi_users where username = 'yourusername';"
Then run this command:
- Change YOUR_OLD_USER_ID
- Change YOUR_NEW_USER_ID

Code: Select all

mysql -uroot -pnagiosxi nagiosxi -e "update xi_usermeta set keyvalue = (select keyvalue from xi_usermetaold where keyname like '%dashboards%' and user_id = 'YOUR_OLD_USER_ID') where keyname like '%dashboards%' and user_id = 'YOUR_NEW_USER_ID';"
That should do it.

Once you're done, drop the extra tables:

Code: Select all

mysql -uroot -pnagiosxi nagiosxi -e "drop table xi_usersold; drop table xi_usermetaold;"

Re: Lost Dashboards/Reports After User Account Recreated

Posted: Thu Mar 04, 2021 6:37 pm
by silverbenz
Thank you @ssax!

I'll give this a go and let you know.

Re: Lost Dashboards/Reports After User Account Recreated

Posted: Fri Mar 05, 2021 4:10 pm
by benjaminsmith
Hi,
I'll give this a go and let you know.
Sounds good. Just update this thread when you're ready