airControl - How to Clean Database


Overview


This article explains how to clean statistics, events, alerts, tasks, and compact the database using the cleanDB tool. This is an easy way to free space on the airControl server. Note: The cleanDB tool is available since v2.0 Final.


Table of Contents


  1. How to Back Up the Database
  2. How to Run the cleanDB in Windowed Environment
  3. How to Run the cleanDB Tool using command line (CLI)
  4. Related Articles

How to Back Up the Database


Back to Top

It is always a good idea to back up the database before performing maintenance. This can be done using the database backup tool located in the Control Panel under Database Backup or using the Manual Backup Guide. See below the Backup Using Desktop Client method, and the Backup Using Web Client one.

Backup Using Desktop Client

Click on the Backup Now button located in the Control Panel under Database Backup.

Backup Using Web Client

Click the Backup Now button located in the the Database Backup page under Settings:


How to Run the cleanDB in Windowed Environment


Back to Top

For servers running on Microsoft Windows and Linux with windowed environment you can use the GUI tool. Start clean_db.bat or clean_db.sh accordingly.


How to Run the cleanDB Tool using command line (CLI)


Back to Top

1. Access airControl Server CLI.

ssh <user>@<airControlServerIP>

2. Run the cleanDB Tool. The cleanDB tool must be run as a privileged user. There is the option to delete Alerts, Events, Statistics, and Tasks.

3. Overview: cleanDB Options

sudo /opt/Ubiquiti/AirControl2/cleanDB ?
-a,--alerts

removes all alerts data

-c,--console runs cleanDB in command line mode
-e,--events <arg>

removes events data that is older than specified days

-h,--help displays this help
-s,--stats <arg>

removes statistics data that is older than specified days

-t,--tasks <arg> removes tasks data that is older than specified days
-v,--vacuum compacts database

 

NOTE: In place of <arg> use the number of days of data you would like to retain. In the examples below 60 days worth of data are retained.

Example: Delete Alerts

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -alerts 60
airControl Database Cleanup Tool v1.0
Stopping server...Done
Deleting data...
Starting server...Done
Database cleanup finished successfully.
Records removed:
statistics: 0
events: 0
tasks: 0
alerts: 342

 Example: Delete Events

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -events 60
airControl Database Cleanup Tool v1.0
Stopping server...Done
Deleting data...
Starting server...Done
Database cleanup finished successfully.
Records removed:
statistics: 0
events: 682
tasks: 0
alerts: 0

Example: Delete Statistics

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -stats 5
airControl Database Cleanup Tool v1.0
Stopping server...Done
Deleting data...
Starting server...Done
Database cleanup finished successfully.
Records removed:
statistics: 12,153
events: 0
tasks: 0
alerts: 0 

Example: Delete Tasks

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -tasks 60
airControl Database Cleanup Tool v1.0
Stopping server...Done
Deleting data...
Starting server...Done
Database cleanup finished successfully.
Records removed:
statistics: 0
events: 0
tasks: 59
alerts: 0

Example: Combined Command

This will remove all Alerts, Events, Statistics, and Tasks except for those within the last 60 days.

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -a 60 -e 60 -s 60 -t 60
airControl Database Cleanup Tool v1.0
Stopping server...Done
Deleting data...
Starting server...Done
Database cleanup finished successfully.
Records removed:
statistics: 12,153
events: 682
tasks: 59
alerts: 342

4. Vacuum Database. After deleting the desired data using the above commands, use the vacuum command to compact the database and reclaim previously used storage.

admin@acserver:~$ sudo /opt/Ubiquiti/AirControl2/cleanDB -v

Related Articles


Back to Top

airControl - How to Back Up and Restore a Database Manually 


We're sorry to hear that!