(ARCHIVED) airControl - How to Back Up and Restore a Database Manually

This article has been archived.

This article is current to the last version of airControl, but will not be updated further since airControl has been retired.

The instructions in this article are mainly for clients using versions previous to the official public release, or if interested in backing up and restoring manually. Otherwise, in version 2.0, you will find a Database Backup feature in the Control Panel of the airControl client, which allows to easily back up and restore databases. No other action is necessary. The location of these backups is: /opt/Ubiquiti/AirControl2/lib/db/dbbackups/

NOTES:When restoring a backup using the Control Panel, you must manually restart the airControl2Server service. With SSH access use:
sudo service airControl2Server restart
Please note that some commands in this article might be longer than the page width, scroll to the side to view them; or click on the Click to Copy icon that appears when hovering over each code block.

Table of Contents

  1. How to Back up a Database
  2. How to Restore a Backup
  3. Other Useful "postgresql" Commands
  4. Related Articles

How to Back Up a Database

Back to Top

1. Back up the database. Issue this command to back up the database. In this example we will use the username postgres, localhost as the host, ac2 as the database name, and ac2backup.sql as the backup file name.

sudo pg_dump -n <schemaName> -F c -T ac2.*statistics -f /opt/Ubiquiti/AirControl2/lib/db/dbbackups/<backup file name>.pgdmp postgresql://<pg_user_name>:<pg_user_password>@<pg_server>:<port>/<db_name>


sudo pg_dump -n ac2 -F c -T ac2.*statistics -f /opt/Ubiquiti/AirControl2/lib/db/dbbackups/ac2backup.pgdmp postgresql://postgres:testpass123@localhost:5432/ac2

 2. View Files. This will place the backup file in the directory. To view, issue the following ls command:

user@ubuntuserver:~$ ls /opt/Ubiquiti/AirControl2/lib/db/dbbackups/ac2backup.pgdmp

 3. Copy File. If desired, you can copy this to another location. There are many ways to do this. For example, using SCP to copy to another computer:

user@ubuntuserver:~$ sudo scp /opt/Ubiquiti/AirControl2/lib/db/dbbackups/ac2backup.pgdmp

How to Restore a Backup

Back to Top

1. Restore Backup File

sudo pg_restore -c -n schemaName -F c -d postgresql://<pg_user_name>:<pg_user_password>@<pg_server>:<port>/<db_name> <backup_file_name_to_restore>

2. Restart airControl2Server Service

sudo service airControl2Server restart


user@ubuntuserver:~$ sudo pg_restore -c -n ac2 -F c -d postgresql://postgres:testpass123@localhost:5432/ac2
jordan@ubuntuserver:~$ sudo service airControl2Server restart

Other Useful "postgresql" Commands

Back to Top

Connect first, using the default postgres user, by following this command:

psql -h localhost -U postgres

Then issue these commands as needed:

\? -- Shows help

\du -- Lists users

\l -- Lists databases

\dn -- Lists schemas

\conninfo -- Displays information about current connection

\q -- Quit/Exit

Related Articles

Back to Top

Intro to Networking - How to Establish a Connection Using SSH

Was this article helpful?
0 out of 0 found this helpful
Can't find what you're looking for?
Visit our worldwide community of Ubiquiti experts for more answers
Visit the Ubiquiti Community