Fully managed cloud. 30-day FREE full featured trial. Start Now
cancel
Showing results for 
Search instead for 
Did you mean: 

xmlrpc to schedule backup ?

mwellbro
Xpert

Hi all,

just played around a bit with the xmlrpc-scripting and tried to "upload" a backup-schedule onto a cluster ( V.6.2.8 ) - here is how it does not work:

 

import xmlrpclib
import ssl
def run(ctx):
    sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    sslcontext.verify_mode = ssl.CERT_NONE
    sslcontext.check_hostname = False
    s = xmlrpclib.ServerProxy("https://user..pwd..addr/cluster1/db_name",context=sslcontext)
    my_str = s.setBackupSchedule({'comment': 'added via xmlrpc',
               'month': '*', 
               'archive': 'v0002',
               'expire': '', 
               'day': '*', 
               'minute': '0', 
               'hour': '16', 
               'id': 8, 
               'level': 2, 
               'enabled': True, 
               'weekday': '*'})

 

Keeps giving me 

[22002] VM error: Fault: <Fault -1: 'ValueError: need more than 7 values to unpack'> (Session: 1682285919927523266)

so I guess my backup definition is wrong ( there are already 7 schedules active, hence the id:8 ) - too bad there´s no example over at https://github.com/exasol/exaoperation-xmlrpc ... anyone using this and/or could tell me how to get this to work ?
Python is certainly not my forte so it might be something blatantly obvious like confusing a dict with a list or something...

Looking forward to any takers 😉

Cheers,
Malte 

1 ACCEPTED SOLUTION

Accepted Solutions

Charlie
Xpert

Hi Malte,

 

the documentation to to xml rpc api is in certain areas nonexistent.

 

You can only replace the whole schedule for a database and not just add an entry, so you have to specify an array of full schedule.

 

A dictionary for each entry would be nice but is not supported 

    db.setBackupSchedule([
        #Active/Inactive, minute, hour, day, month, weekday, volume, level, Expire in seconds, Comment
        [False,  '1', '3', '*', '*','*', 'v0002','0', 3600*24, 'Test XMLRPC']
    ]
    )

 

This should create a backup with level 0 that is not active and runs every day at 03:01 and expires after 24 hours. This will also replace the existing schedule entries.

View solution in original post

5 REPLIES 5

Charlie
Xpert

Hi Malte,

 

the documentation to to xml rpc api is in certain areas nonexistent.

 

You can only replace the whole schedule for a database and not just add an entry, so you have to specify an array of full schedule.

 

A dictionary for each entry would be nice but is not supported 

    db.setBackupSchedule([
        #Active/Inactive, minute, hour, day, month, weekday, volume, level, Expire in seconds, Comment
        [False,  '1', '3', '*', '*','*', 'v0002','0', 3600*24, 'Test XMLRPC']
    ]
    )

 

This should create a backup with level 0 that is not active and runs every day at 03:01 and expires after 24 hours. This will also replace the existing schedule entries.

mwellbro
Xpert

Thanks @Charlie ! Will test and mark as solution today 🙂 

Hey @exa-Chris , see: we do talk here 😉

codrin
Xpert

Thanks for showing the example list of required arguments @Charlie . I am trying to run this code from Terraform and when running it with #Active/Inactive True, however, the schedule is added to the backup schedule, but not 'Applied' and thus no backup is made. Do you recognize this issue @mwellbro ? What is the XMLRPC equivalent of hitting the 'Apply' button in ExaOperation, which then shows the graphical representation of the backup schedule and enables backups to be made? Thanks!

 

mwellbro
Xpert

Hi @codrin ,

can´t seem to verify this, just tried it on a freshly spun up AWS cluster:

pre_set_backup.png

Then I ran this one here ( sorry for PYTHON instead of PYTHON3 but I was too lazy to look up what xmlrpclib is in PYTHON3 ) :

 

 

CREATE SCHEMA MY_SCHEMA;

CREATE OR REPLACE PYTHON SCALAR SCRIPT MY_SCHEMA.SET_BACKUP() RETURNS VARCHAR(2000) AS
import xmlrpclib
import ssl
def run(ctx):
    sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    sslcontext.verify_mode = ssl.CERT_NONE
    sslcontext.check_hostname = False
    s = xmlrpclib.ServerProxy("https://xmlUser:YouWishYouKnew@3.125.104.238/cluster1/db_exasol",context=sslcontext)
    s.setBackupSchedule([
        #Active/Inactive, minute, hour, day, month, weekday, volume, level, Expire in seconds, Comment
        [True,  '1', '3', '*', '*','*', 'v0002','0', 3600*24, 'Test XMLRPC']
    ]
    )
/

SELECT MY_SCHEMA.SET_BACKUP() FROM dual;

 

 


Result in client:
client_result.PNG

And this is what ExaOperation showed me right afterwards:

post_set_backup.png

Exa-Version:
exa_version.png

update: also checked it with a remote volume (as I used an internal one in my test before) - still the same outcome, not sure why it seems to behave differently on your end...what version of Exasol are you using for this ?

Cheers,
Malte

codrin
Xpert

Thanks for the elaborate exploration @mwellbro. It took a bit of trial and error, but I found my issue. Setting a schedule with '*' for Weekday works, but '1,2,3,4,5' for Weekday does not work for me. It will show but not get 'applied'. Maybe a parsing issue behind the scenes? I tried escaping with a backslash but that did not work. * will work for us for now, so I can Terraform including a daily backup schedule. Thanks!