Categories
Cloudvue Knowledge Support Cloudvue Gateway Support Categories

Dropping and Creating the smartvuedb Database

Description 

At times it may be necessary to drop (delete) and create the smartvuedb database.  WARNING VIDEO LOSS is expected, and except for rare occasions this should only be performed on newly deployed NVRs.

Product 

Cloudvue Gateway

Prerequisite

  • ssh access to the Cloudvue Gateway
  • see KB #13051 “Cloudvue SSH Tunneling” or KB #13667 “Tunneling to a Cloudvue Gateway From a Local Windows Machine”

Solution

Issue the following commands from terminal

** WARNING ** WILL RESULT IN VIDEO LOSS

<code>sudo service cron stop <br>mysqldump -u root -p smartvuedb camera camera_setting camera_view nvr_setting schedule user user_setting user_Status User_view view > /home/smartvue/smartvuedb_backup.sql <br>sudo mysql smartvuedb -s -e “drop database smartvuedb;”<br>sudo mysql -s -e “create database smartvuedb;”<br>sudo -i <br> bash /opt/smartvue/services/nvr-database-migrate/installer.sh<br>bash /smartvue/updater.sh<br>mysql -u root smartvuedb -p < /smartvue/mysql/multi-tables_smartvuedb_backup_file.sql<br>exit<br>sudo service cron start</code>


Command Explanation

cron stop – Stops scripts from being launched by cron during this process

msyqldump – (Optional) can be used to create a backup of specified tables within the existing smartvuedb database

drop database smartvuedb – Removes the existing smartvuedb database

create database smartvuedb – creates an empty smartvuedb database

sudo -i – switch to root user

installer.sh – runs the installer script which sets permissions for smartvuedb and will return the following lines if successful

++ pwd -P <br>+ SERVICE_DIR=/root <br>SERVICE_DIR=/root <br>SMV_NVR_DB_USER=root <br>/root/node_modules/db-migrate/bin/db-migrate up <br> /opt/smartvue/services/nvr-database-migrate/installer.sh: line 4: /root/node_modules/db-migrate/bin/db-migrate: No such file or directory <br>exit 127

updater.sh – runs the updater script which populates default values in certain tables within smartvuedb database and takes several minutes to complete.

mysql -u root smartvuedb -p – (Optional) can be used to import tables previously backed up with the mysqldump

cron start – Starts cron service

Categories
Cloudvue Knowledge Support Cloudvue Gateway Support Categories Products

Cloudvue Gateway Camera Already Exists

Description 

When attempting to add a camera to the Cloudvue Gateway an error message appears “Camera Already Exists”. Typically, this happens when the local database is out of sync with the cloud database. Removing the camera from the local database then re-adding triggers a new sync which resolve the issue. Below are instructions for removing the camera from the local Cloudvue database.

Product 

  • Cloudvue Gateway

Solution

Overview

The following steps should be used to remove the duplicate camera from the Cloudvue Gateways database.

  • SSH to the Cloudvue Gateway
  • Launch MariaDB Monitor
  • Display Camera Table Contents
    • Use the MAC address to Identify the Camera
  • Delete the Camera
  • Display Camera Table Contents
    • Check the changes
  • Delete associated Camera Settings
  • Close MariaDB Monitor

SSH to the Cloudvue Gateway

  • sudo ssh -p 7627 smartvue@[IPADDRS]
    • Where [IPADDRS] is the IP address of the Cloudvue Gateway

Launch MariaDB monitor and Access The Smartvue Database

  • mysql -u root smartvuedb

Display Camera Table Contents

  • select * from camera;

Identify The Camera

  • Use the MAC to find the camera which needs to be deleted
    • Make note of the id and deleted_at fields
    • NULL in deleted_at indicates that camera is active

Delete The Camera

  • update camera set deleted_at =  created_at  where id = [id];
    • Where [id] is the cameras id

Check Your Work

  • List the cameras 
    • select * from camera;
  • Verify that the  deleted_at field is no longer NULL but is the same as the created_at field

Delete the Cameras Settings

  • delete from camera_setting where camera_id = [id];
    • Where [id] is the cameras id

Close MariaDB monitor

  • \q

Pro Tip:  To restore a camera change the deleted_at field  to NULL

update camera set deleted_at = NULL where id = [id];

  • Where [id] is the cameras id