Export/import profile

Post Reply
andrea.schneider
Posts: 21
Joined: Fri Dec 04, 2009 8:38 am

Export/import profile

Post by andrea.schneider »

Hi
How can I export a specific profile from one webinator installation to another? I know I can delete a profile entry with
"delete from options where Profile='myprofile'",
but how can I create/insert a new profile with data from the other webinator installation? I do not need the walk data only the content of the profile.

We're having a "Webinator Professional Version 5" license


Thanks....
User avatar
mark
Site Admin
Posts: 5514
Joined: Tue Apr 25, 2000 6:56 pm

Export/import profile

Post by mark »

Here's a script that will export and import settings.
It will change the rewalk type to New so the first
walk will work. See the notes within the script as well.

<script language=vortex>

<a name=main public>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<vxcp htmlmode off>
Basic export and import of Webinator profile settings.
Usage: texis profile="Your_Profile_Name" $url/exportprofile.txt >settings.lst
or: texis $url/importprofile.txt <send "<">settings.lst
Notes: This assumes it is creating a profile. If a profile by the same
name already exists import will make a mess with duplicate settings.
You should check/change the values for SS_dataspace and SS_db in the
exported settings file before importing.
</a>

<a name=outstring s>
<sandr '"' '""' $s>
"$ret"<!--nop-->
</a>

<a name=exportprofile public>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<vxcp htmlmode off>
id|Profile|Name|Type|Int|Float|String|Strlist
<sql row "select * from options where Profile=$profile and Name not in ('SSc_nbytes','SSc_npages','SSc_walked','SSc_walknow','SSc_walking','SSc_ndbs','SSc_schedule','SSc_schedulehr','SSc_LastWalkType','SSc_LastWalkStart','SSc_LastWalkFinish','SSc_FailedWalkType','SSc_FailedWalkStart','SSc_FailedWalkFinish','SSc_CurrentWalkType','SSc_CurrentWalkStart') and Name not matches 'SSc_pause%'">
$id|<outstring s=$Profile>|<outstring s=$Name>|$Type|$Int|$Float|<outstring s=$String>|$Strlist
</sql>
</a>

<a name=importprofile public>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<vxcp htmlmode off>
<timport "csv |
field id counter 1
field Profile varchar 2
field Name varchar 3
field Type varchar 4
field Int long 5
field Float double 6
field String varchar 7
field Strlist strlst 8
" fromfile "-">
<if $Name eq "SSc_rewalktype">
<$String="new">
</if>
<sql novars "insert into options values(counter,$Profile,$Name,$Type,$Int,$Float,$String,$Strlist)"></sql>
<if $Name eq "SS_dataspace">
<sysutil mkdir parents $String>
<elseif $Name eq "SS_db">
<sysutil mkdir parents $String>
<createdb $String "Klaatu!" "">
</if>
</timport>
$loop records imported
</a>

</script>
andrea.schneider
Posts: 21
Joined: Fri Dec 04, 2009 8:38 am

Export/import profile

Post by andrea.schneider »

Hi Mark
Thanks for the script.

I got two problems, the catgeories.tbl is missing and the column Exclude by Field --> Meta Field is empty. The values are in the created .lst file but seem not to be imported.

I can suppress the creation for the db1 folder to fix the first problem, but what can I do to get the entries of the "Meta Field" Column?

Thanks for your help...
User avatar
mark
Site Admin
Posts: 5514
Joined: Tue Apr 25, 2000 6:56 pm

Export/import profile

Post by mark »

The categories table will be created when you do a new walk.

Meta Field works for me. Do you get any errors during import?
What do you have in your dump for these:
SSc_exquery
SSc_exfieldsel
SSc_exfieldinp
SSc_exwhat
andrea.schneider
Posts: 21
Joined: Fri Dec 04, 2009 8:38 am

Export/import profile

Post by andrea.schneider »

Hi Mark
I guess I found the problem, the dump I got has the first rows as you can see below. I assume because the entries of
"SSc_exfieldinp" are listed before the row 4ca5e07419b|"iech_de_cug04"|"SSc_exquery/SSc_exfieldsel/SSc_exfieldinp/SSc_exwhat"|String|0|0|""|
it isn't able to import the values. If I move the "SSc_exfieldinp" below
"4ca5e07419b|"iech_de_cug04"|"SSc_exquery/SSc_exfieldsel/SSc_exfieldinp/SSc_exwhat"|String|0|0|""|"
it works fine.
I have exported another profile and there I got another order of rows, may I add any "order by" clause to be
sure the "SSc_exfieldinp" entries are not exported as first row?

Dump with wrong order of rows:
id|Profile|Name|Type|Int|Float|String|Strlist
4ca5e0741a0|"iech_de_cug04"|"SSc_exfieldinp"|String|0|0|"type
type
type
type
type
type
"|
4ca5e07417f|"iech_de_cug04"|"SSc_extensions"|String|0|0|".htm .pdf .doc .xls .ppt .swf"|
4ca5e07419d|"iech_de_cug04"|"SSc_urlurl"|String|0|0|""|
4ca5e07419e|"iech_de_cug04"|"SSc_pageurl"|String|0|0|""|
4ca5e07419f|"iech_de_cug04"|"SSc_attachwalkerrors"|String|0|0|"N"|
4ca5e0741a1|"iech_de_cug04"|"SSc_linkreport"|String|0|0|""|
4ca5e0741a2|"iech_de_cug04"|"SSc_proxyusername"|String|0|0|""|
4ca5e07419b|"iech_de_cug04"|"SSc_exquery/SSc_exfieldsel/SSc_exfieldinp/SSc_exwhat"|String|0|0|""|
User avatar
mark
Site Admin
Posts: 5514
Joined: Tue Apr 25, 2000 6:56 pm

Export/import profile

Post by mark »

The order shouldn't matter. In fact, the SSc_exquery/SSc_exfieldsel/SSc_exfieldinp/SSc_exwhat entry is not technically needed at all.

Can you provide the full dump of
SSc_exquery
SSc_exfieldsel
SSc_exfieldinp
SSc_exwhat
so I can try with your settings.

Or supply your whole dump. You can mask out urls, users, and passwords as their actual values won't matter for testing restore.
andrea.schneider
Posts: 21
Joined: Fri Dec 04, 2009 8:38 am

Export/import profile

Post by andrea.schneider »

Hi Mark
You're right it works, the problem is in my enhanced version of the import script. Could you please give me some assistance with this? I've tried to add a check if the profile which should be imported already exists, and a host replacement.
The execution of timport twice seems to raise the problem. When I don't use the check it imports 2 rows more and I can also see the Meta Field entries.

I don't understand completely how this timport works. I have assumed I can import the file as many times as I need it, but it seems to remove lines when I execute it again.

Here is my changed version of the script:

<script language=vortex>

<a name=main public>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<vxcp htmlmode off>
<VERB>

</VERB>

***************************************************************************************************************************
* Basic export and import of Webinator profile settings. *
***************************************************************************************************************************
Usage Export: texis profile="Your-Profile-Name" $url/exportprofile.txt >Your-List-Name.lst
---------------------------------------------------------------------------------------------------------------------------
Usage Import: texis fromHost="current.domain.ch" toHost="new.domain.ch" $url/importprofile.txt <send "<">Your-List-Name.lst
---------------------------------------------------------------------------------------------------------------------------
NOTES: The Import creates a new profile with Rewalk-Type "New". No database is created, must start a walk to get data.
---------------------------------------------------------------------------------------------------------------------------
</a>

<a name=outstring s>
<sandr '"' '""' $s>
"$ret"<!--nop-->
</a>

<a name=exportprofile public>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<vxcp htmlmode off>
id|Profile|Name|Type|Int|Float|String|Strlist

<sql row "select * from options where Profile=$profile and Name not in ('SSc_nbytes','SSc_npages','SSc_walked','SSc_walknow','SSc_walking','SSc_ndbs','SSc_schedule','SSc_schedulehr','SSc_LastWalkType','SSc_LastWalkStart','SSc_LastWalkFinish','SSc_FailedWalkType','SSc_FailedWalkStart','SSc_FailedWalkFinish','SSc_CurrentWalkType','SSc_CurrentWalkStart') and Name not matches 'SSc_pause%'">
$id|<outstring s=$Profile>|<outstring s=$Name>|$Type|$Int|$Float|<outstring s=$String>|$Strlist
</sql>
</a>

<a name=importprofile public fromHost toHost>
<if '' ne $REMOTE_ADDR>Not for web!<exit></if>
<$mustBeImported=0>
<$profileName="">
<vxcp htmlmode off>
<timport "csv |
field Profile varchar 2
" fromfile "-">
<$profileName=$Profile>
<sql row "select distinct Profile as ProfileValue from options where Profile=$Profile"></sql>
<if $ProfileValue neq $Profile>
<$mustBeImported=1>
</if>
<break>
</timport>

<if $mustBeImported eq 1>
<timport "csv |
field id counter 1
field Profile varchar 2
field Name varchar 3
field Type varchar 4
field Int long 5
field Float double 6
field String varchar 7
field Strlist strlst 8
" fromfile "-">
<if $Name eq "SSc_rewalktype">
<$String="new">
</if>
<strstr $fromHost $String>
<if $ret gt -1>
<sandr $fromHost $toHost $String><$String = $ret>
</if>

<sql novars "insert into options values(counter,$Profile,$Name,$Type,$Int,$Float,$String,$Strlist)"></sql>
<if $Name eq "SS_dataspace">
<sysutil mkdir parents $String>
</if>
</timport>
$loop records imported
Profile "$profileName" has been created!
<else>
Profile "$profileName" already exists!
</if>
</a>

</script>
User avatar
mark
Site Admin
Posts: 5514
Joined: Tue Apr 25, 2000 6:56 pm

Export/import profile

Post by mark »

In the <timport> it does
fromfile "-"
which reads from the standard input stream. You can't read that twice. You could take a filename and read from that twice, or timport once without row then loop over the variables for the 2nd pass, or write it to not need 2 passes. Something like this maybe
<timport ...>
<if $loop eq 0>
<sql max=1 novars "select Profile from options where Profile=$Profile">
Profile $Profile already exists. Bailing out.
<exit 1>
</sql>
</if>
... fixup and insert ...
</timport>
andrea.schneider
Posts: 21
Joined: Fri Dec 04, 2009 8:38 am

Export/import profile

Post by andrea.schneider »

Hi Mark
Thanks for this, it works great!
Post Reply