Flussonic Watcher documentation

The Watcher database

This section provides the instructions on how to maintain the database used by Watcher.
  • Migrate to PostgreSQL (necessary starting from version 19.03)
  • Update the database structure manually (migth be necessary in some cases, Watcher will inform you about it)

Migration from SQLite to PostgreSQL Anchor Anchor x2

  1. Back up these files:

    /etc/flussonic/flussonic.conf

    /opt/flussonic/priv/vsaas.db

  2. Install the latest version of Flussonic Watcher (to do this, it is enough to update Flussonic Media Server). Run two commands:

    apt update 
    

    and

    apt install flussonic
    

    Learn more about the update process

  3. Back up all the data by using our migration tool:

    cd /opt/flussonic/apps/vsaas
    
    /opt/flussonic/bin/python -m manage backup create
    

    The tool creates a file like this: /opt/flussonic/apps/vsaas/backups/20190215201434-b62d21842ab7-WatcherBackup.gz

  4. Install PostgreSQL

  5. Edit the database line in the Flussonic configuration file flussonic.conf:

    database postgresql://vsaas:vsaas@localhost/vsaas_production; You can edit text files with the text editor nano.

  6. Reload the Flussonic service:

    /etc/init.d/flussonic restart
    
  7. Restore data from the file that was created by the migration tool:

    cd /opt/flussonic/apps/vsaas 
    
    /opt/flussonic/bin/python -m manage backup restore -d 20190215201434
    

Installing and configuring PostgreSQL Anchor Anchor x2

  • To install PostgreSQL, with root access in the console execute the command:
apt install postgresql
  • Create a PostgreSQL user and a database. Type two commands in the console one by one. First, create the user vsaas:
sudo -u postgres createuser -P vsaas

The system will prompt you to enter the password that will be used for the user vsaas:

Enter password for new role: (come up with and enter Watcher super admin password)

Enter the password one more time:

Enter it again: (re-enter Watcher super admin password)

  • Create the database vsaas_production with the created user vsaas as the owner:
sudo -u postgres createdb -O vsaas -e -E UTF8 -T template0 vsaas_production

System's response if the database was created successfully: CREATE DATABASE vsaas_production OWNER vsaas ENCODING 'UTF8' TEMPLATE template0

  • Go to the IP cameras in the administrative interface to Flussonic Media Server (see Watcher UI and Flussonic UI below) and specify the path to the database in the Database path box.

Inportant. Replace VSAAS_PASSWORD with the real password of the vsaas user that you created in previous steps.

Installing Watcher Single

Updating the database structure Anchor Anchor x2

Some Flussonic Watcher updates include structural changes to the database. In this case, you will see the following message:

Updating the Database Structure

The script /opt/flussonic/contrib/watcher_db_migrate.sh adds changes to the database structure.

Run this script on the server side manually.

Here is an example of the success log:

# /opt/flussonic/contrib/watcher_db_migrate.sh
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade dfd74e510414 -> 1822b8f25e20, agent:model, agent:camera
INFO  [alembic.runtime.migration] Running upgrade 1822b8f25e20 -> 1a71a9477bbb, streamer: cluster_key
INFO  [alembic.runtime.migration] Running upgrade 1a71a9477bbb -> 7a3ab2550cab, streamer_fkey cascade
Restarting Watcher

After the Flussonic Watcher restart, you will be able to use the Watcher GUI.

If while running watcher_db_migrate.sh will be similar error to:

alembic.util.exc.CommandError: Can't locate revision identified by 'ebdce5515b6d

Then install previous version (version before update/downgrade) and run:

cd /opt/flussonic/apps/vsaas
/opt/flussonic/bin/python -m manage db downgrade

Important! Backup your database before running watcher_db_migrate.sh script.

The database type and location is stored in the configuration file /etc/flussonic/flussonic.conf.

  • PostgreSQL:
vsaas {
  database postgresql://vsaas:vsaas_password@localhost/vsaas_production;
}
  • Make a reserve copy using the pg_dump utility:
pg_dump -h localhost -U vsaas -d vsaas_production > /path/to/backup/vsaas.sql

Answer: Password: enter password vsaas_password, that you specified for vsaas user