Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions on how to run #1

Open
jhaines1989 opened this issue Sep 4, 2018 · 23 comments
Open

Instructions on how to run #1

jhaines1989 opened this issue Sep 4, 2018 · 23 comments
Assignees
Labels

Comments

@jhaines1989
Copy link

Hi Peter ,

This might be a silly question and I apologize in advance.

Is there any instruction on how I actually run this and what OS it needs to be run on ?

@peterM
Copy link
Owner

peterM commented Sep 4, 2018

Hi Jordan
The tool is mainly for Windows (10) OS.

You can run executable from console or install it as Windows service.
How to use:

  • Download release zip file.
  • Unpack zip file somewhere
  • Open and update config file 'MalikP.Ubiquiti.DatabaseExporter.Service.exe.config' to fit your environment - check readme
  • Create destination folder for files,
  • Create database for exported data and create schema from script
  • Run Console (WIN+R and enter CMD)
  • Navigate to path where tool is extracted
  • run 'MalikP.Ubiquiti.DatabaseExporter.Service.exe'
  • data should be extracted to target folder (depending from configuration) & data should be written to database (depending from configuration)

@jhaines1989
Copy link
Author

Thanks for the info.
I can't seem to find any files that end in service.exe in the .zip I downloaded.
There is an app.config that I have found that seems to have the parameters mentioned in the readme.

Now all I need know which file will execute the program and I don't have one called "MalikP.Ubiquiti.DatabaseExporter.Service.exe"

@peterM
Copy link
Owner

peterM commented Sep 5, 2018

Did you download zip file from here ?

@jhaines1989
Copy link
Author

Ah I was clearly downloading the source code !

Thanks for your help and sorry for bothering you with something so simple.

@peterM
Copy link
Owner

peterM commented Sep 5, 2018

No problem. I hope it will work well also in your environment..

@peterM peterM self-assigned this Sep 5, 2018
@peterM peterM added the How to label Sep 5, 2018
@peterM
Copy link
Owner

peterM commented Sep 11, 2018

@abzkebabs Could you provide me some feedback ?
like:

  • did it work in your environment ?
  • how do you like it ?
  • is it helpfull ?
    Thanks.

@jhaines1989
Copy link
Author

Hi Peter ,

I did give it a go and the CMD prompt just stayed on all day with out any data being written to my file location.
I was just trying to do a dump to file as a test first before moving to SQL and the config had no SQL connection configured in it.

any ideas on why it would just hang and not do anything ? I was running it on Server 2016 FYI.

Was planning on coming back to have another go soon when I have some spare time at work.

Thanks

@peterM
Copy link
Owner

peterM commented Sep 17, 2018

Could you send me your config file (without passwords) to [email protected] and also attach some information about your controller ?

Is it CloudKey or Windows based controller ?

or try this (valid in case you are using cloudkey):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<startup>
		<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
	</startup>
	<appSettings>
		<add key="Use-Encrypted-Psswords" value="false"/>

		<!-- certificate have to be in certification store local machine -->
		<add key="Encryption-Certificate-Identifier" value="[Encryption-Certificate-Serial-Number]" />

		<add key="Backup-Path" value="C:\UnifiBackup" />
		<add key="Mongo-Connection-String" value="mongodb://127.0.0.1:27117" />

		<!-- Everytim turn off pooling by `Pooling=false;` -->
		<add key="Sql-Connection-String" value="Server=[Server];Database=Ubiquiti-Unifi-Backup;Pooling=false;" />
		<add key="Sql-User-Id" value="" />

		<!-- password encrypted by certificate -->
		<add key="Sql-User-Password" value="" />

		<!-- have to be greater than 0-->
		<add key="Sql-Batch-Size" value="100"/>

		<add key="Export-To-FS" value="true" />
		<add key="Export-To-DB" value="false" />

		<!-- 
			use ssl tunel when you want extract data from cloud key 
			in case you want to extract data from windows based controller set 'Use-SSH-Tunel' to 'False'
		-->
		<add key="Use-SSH-Tunel" value="true" />
		<add key="SSH-Tunel-Host" value="IP-OF-UNIFI-CONTROLLER" />
		<add key="SSH-Tunel-UserName" value="admin" />

		<!-- password encrypted by certificate -->
		<add key="SSH-Tunel-Password" value="YOUR-PASSWORD" />
		<add key="SSH-Forward-Host-From" value="127.0.0.1" />
		<add key="SSH-Forward-Port-From" value="27117" />
		<add key="SSH-Forward-Host-To" value="127.0.0.1" />
		<add key="SSH-Forward-Port-To" value="27117" />

		<add key="Blacklisted-Table-Names" value=""/>

	</appSettings>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
				<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
			</dependentAssembly>
		</assemblyBinding>
	</runtime>
</configuration>

and do not forget change key:

<add key="SSH-Tunel-Host" value="IP-OF-UNIFI-CONTROLLER" />

and key :

<add key="SSH-Tunel-Password" value="YOUR-PASSWORD" />

@juanpmox
Copy link

Hello Peter, in first place, thanks for this awsome utility!

I'm using it on my network, and dumping data from CloudKey to file system is going wel.

I have problems when try to dump data to sql. I'm using a configuration based on the settings you suggest on Sept 17, 2018

The SQL related lines, are


	<!-- Everytim turn off pooling by `Pooling=false;` -->
	<add key="Sql-Connection-String" value="Server=MYSERVER;Database=Ubiquiti-Unifi-Backup;Pooling=true;" />
	<add key="Sql-User-Id" value="user-sql-login" />

	<!-- password encrypted by certificate -->
	<add key="Sql-User-Password" value="user-sql-password" />

Monitoring the process, I've found that none connections are made from the MalikP.Ubiquiti.DatabaseExporter.Service.exe to the SQL Server.

Am I missing some configuration or pre-req installation?

Thank you some much, in advance.
Best regards.

@peterM
Copy link
Owner

peterM commented May 23, 2019

Hi @juanpmox

Please try these steps.:

please let me know if it helped or not

@juanpmox
Copy link

Unfortunately, same result :(

  • DB Ubiquiti-Unifi-Backup, created with script
  • DB schema, created, with the script too

Ran the tool again, from Windows cmd.exe, but none data is imported to DB

@peterM
Copy link
Owner

peterM commented May 25, 2019

Hmm .... 🤔
I have several questions:

  • Did you try run it as administrator ?
  • Did you run from command prompt / console or as windows service ?
  • did you allow export to db ? <add key="Export-To-DB" value="true"/>
  • could you send me your config (anonymized)

@juanpmox
Copy link

juanpmox commented Jun 2, 2019

my comments below:
Did you try run it as administrator ? => Yes
Did you run from command prompt / console or as windows service ? => Yes, form console, and with scheduled task
did you allow export to db ? => Yes
could you send me your config (anonymized) => Yes, I'll sending you the config file to [email protected]

@peterM
Copy link
Owner

peterM commented Jun 2, 2019

@juanpmox Thank you for mail. I checked config, and i do not see any error. Is exactly the same as mine. I think there have to be something wrong in code.

Could you try with SA user ?

For example i use something like this:

<add key="Sql-Connection-String" value="Server=sql.domain.local;Database=Ubiquiti-Unifi-Backup;Pooling=false;"/>
<add key="Sql-User-Id" value="sa"/>
<add key="Sql-User-Password" value=""/>

I think I have to add some more logging.


EDIT
Could you try new version 1.3.1.0 from here ?

@juanpmox
Copy link

juanpmox commented Jun 5, 2019 via email

@peterM
Copy link
Owner

peterM commented Jun 5, 2019

@juanpmox this log is from not the most new version right ?
I think the problem is that sql Exporter instance is not created so is not used.

In the most new version i replaced 'IoC' library and also add log to show you what exporters are created. Please try this new version and sorry for these problems.

In case SQL exporter is created you should see as firs lines in console after start.

There are [2] resolved exporters.
        There is [UnifiToFileSystemExporter] exporter resolved.
        There is [UnifiToSqlDatabaseExporter] exporter resolved.

@juanpmox
Copy link

Hi Peter,

I'm back just to say that my problem is SOLVED now. My issue was related to UAC on the Windows 10 computer that I used to get the Unifi data. To get the Exporter working, in my case, I need to do that:

  • Download release zip file.
  • Right click the downloaded, zip file, -> Properties -> mark the checkbox "Unblock" -> then Ok
  • Unpack zip file somewhere
  • ...

Now I' ve get information exported to DB and FS, without any problems.

Thank you very much for this tool, and you support.

Best regards

@peterM
Copy link
Owner

peterM commented Jun 11, 2019

Hi.
Oh niice.
Thank you also for patience feedback and warming words :)
Peter

@rkwtemp1
Copy link

1st. thanks a lot for this utility.
unfortunately i do not get any traffic stats exported which would be in in mongodb ace_stats. like daily a
or hourly traffic statistics. i only receive a folder named "ace" in the UnifiBackup-Folder. by the waay .. i'm using the cloudkey g2+
please give me a tip about what maybe is set up wrong.

@peterM
Copy link
Owner

peterM commented Nov 30, 2020

Hi @rkwtemp1 i am not sure. I did not test it with Gen 2 or UDM/UDM-Pro.
I have UDM-Pro now at home so maybe if i will have spare time i will try it. For now i could not say more about it. Maybe during time they changed something. P.

EDIT:

I know where the problem is .. i will try export my data and then will write you workaround until i fix it :)

EDIT2:

Blacklist these tables like is bellow:

<add key="Blacklisted-Table-Names" value="ace.ipsalert;ace.featuremigration;ace.storeddpistats" />

And i think you already used to login root instead of admin

<add key="SSH-Tunel-UserName" value="root" />

Then it should work.

EDIT3:

Download new version 1.4.0.0 Do NOT overwrite your config. At least if you do not want to configure everything again ;)
And do not forget to update your SQL DB Schema if you use also SQL DB. How to do that please check Readme. I added section to end of the document.

EDIT4:

Last version of controller: 6.0.41 has also new table ace.apgroup whitch is not supported now by utility. Add it to blacklist.

@Whaagh4800
Copy link

Hi There, I see this is a bit old. I am wondering does this work on a device that is linked to the unifi cloud dashboard?

@peterM
Copy link
Owner

peterM commented Jun 17, 2024

Yes its old .. i did not have lot of time to upgrade it to most new version of UniFi Network
Unfortunately No .. it will not work .. It works the way that you connect to internal MongoDB database and just export data. So cloud version of Dashboard will not work.

@Whaagh4800
Copy link

Thank you very much for the quick response, appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants