Migration » History » Version 2
Nicolas C, 2014-11-21 14:17
1 | 1 | Nicolas C | h1. Migration |
---|---|---|---|
2 | 2 | Nicolas C | |
3 | 1 | Nicolas C | If you want to migrate between Tvheadend instances, one possible approach is to configure your new instance in advance, reading your muxes via http. Of course if you have a large number of muxes, just loading on by one could be tedious, so it's better to do it programmatically. Refer to the attached script. |
4 | |||
5 | This script has been tested on migrating a 3.4 server to a 3.9 server. |
||
6 | |||
7 | <pre> |
||
8 | #!/usr/bin/env python |
||
9 | import time |
||
10 | import urllib |
||
11 | import urllib2 |
||
12 | import json |
||
13 | #Source IP of your TVHeadend Server |
||
14 | ipsrc='192.168.0.9' |
||
15 | #Target IP |
||
16 | ipdst='192.168.0.254' |
||
17 | #Old Network Name |
||
18 | onn='Astra28' |
||
19 | #New Network UUID |
||
20 | nnu='7cc8273901fadc4f5e8b65a4bca392fd' |
||
21 | url = 'http://'+ipsrc+':9981/api/mpegts/mux/grid?start=0&limit=400' |
||
22 | url=urllib2.urlopen(url) |
||
23 | json_string=url.read() |
||
24 | data = json.loads(json_string) |
||
25 | entries = data['entries'] |
||
26 | if entries: |
||
27 | for entry in entries: |
||
28 | if entry['network']==onn: |
||
29 | print "Creating MUX: ' + entry['name'] |
||
30 | conf = { 'enabled' : 'true', |
||
31 | 'epg' : 0, |
||
32 | 'scan_state' : 0, |
||
33 | 'iptv_url' : 'http://'+ipsrc+':9981/stream/mux/' + entry['uuid'], |
||
34 | 'iptv_interface' : 'eth0', |
||
35 | 'iptv_atsc' : '', |
||
36 | 'iptv_muxname' : entry['name'], |
||
37 | 'iptv_sname' : '', |
||
38 | 'charset' : '', |
||
39 | 'pmt_06_ac3' : '', |
||
40 | 'priority' : 0, |
||
41 | 'spriority' : 0, |
||
42 | } |
||
43 | data = { 'uuid' : nnu, |
||
44 | 'conf' : json.JSONEncoder().encode(conf), |
||
45 | } |
||
46 | posturl = 'http://'+ipdst+':9981/api/mpegts/network/mux_create' |
||
47 | postdata = urllib.urlencode(data) |
||
48 | req = urllib2.Request(posturl, postdata) |
||
49 | response = urllib2.urlopen(req) |
||
50 | the_page = response.read() |
||
51 | print "Sleeping for 60 seconds to allow initial scan" |
||
52 | time.sleep(60) |
||
53 | </pre> |