Manually entering data into DB

Status
Not open for further replies.

Scubadave112

Member
Jan 24, 2020
122
19
18
36
This could be a very dumb question and if so I apologize.

I don't see a way to export device profiles from fusion so i see that there are three tables (profiles, keys and settings). I want to just copy the table data to the DB on another server. I don't mean just copy all, mostly just they keys cause we have a lot of crazy profiles out there with sidecars and whatnot.

so here is my question (Finally):

1. on the profile table, if I enter a name, true and description and leave the domain uuid and profile uuid blank will it just generate ad profile uuid on its own or and leave the domain null (making it a global profile)?

2. same question in regard to the profile key table, if i enter the proper domain, profile uuid and all my other desired values but leave the key profile uuid blank will it generate its own?

maybe im over complicating what im doing but it is so time consuming manually entering this all in via the web. because you select yealink for the vendor but the type you have to be sure to chose the propper option under then vendor (unless you hit save). also you have to keep hitting save to generate a new line (very annoying).
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,416
376
83
On the device profile record, the drop down for Domain does have a "Global" option. I have never tried using it.

As far as copying device profiles to another server, below are a couple of "rough and ready" bash scripts that I use for this purpose, please use/adapt at your own risk. Both commands take a domain UUID as an argument:

export_device_profile.sh

Code:
#!/bin/bash

#settings
EXPORT_DIR="/tmp"
export PGPASSWORD="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
db_host=127.0.0.1
db_port=5432

if [ "$#" -lt 1 ]; then
    echo "You must supply the uuid of the required domain as a command line argument."
    exit 1
fi

psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy (select * from v_device_profiles where domain_uuid = '$1') to '${EXPORT_DIR}/v_device_profiles_$1.tsv'"
psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy (select * from v_device_profile_settings where domain_uuid = '$1') to '${EXPORT_DIR}/v_device_profile_settings_$1.tsv'"
psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy (select * from v_device_profile_keys where domain_uuid = '$1') to '${EXPORT_DIR}/v_device_profile_keys_$1.tsv'"

exit 0


import_device_profile.sh

Code:
#!/bin/bash

#settings
EXPORT_DIR="/tmp"
export PGPASSWORD="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
db_host=127.0.0.1
db_port=5432

if [ "$#" -lt 1 ]; then
    echo "You must supply the uuid of the required domain as a command line argument."
    exit 1
fi

psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy v_device_profiles from '${EXPORT_DIR}/v_device_profiles_$1.tsv'"
psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy v_device_profile_settings from '${EXPORT_DIR}/v_device_profile_settings_$1.tsv'"
psql --host=$db_host --port=$db_port --username=fusionpbx -c "copy v_device_profile_keys from '${EXPORT_DIR}/v_device_profile_keys_$1.tsv'"

exit 0

I hope that helps.
Adrian.
 
Status
Not open for further replies.