I'm looking to automate backups in ML7 using rest-api. Since that's not available out of the box, I figured that I can just add new extension and setup script with curl command on desired schedule. Sounds easy but for some reason when I try installing my extensions it spits out 'invalid content' and log is showing:
• RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid backupdb extension: could not parse XQuery extension backupdb; please see the server error log for detail XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_; backupdb either is not a valid module or does not provide extension functions (delete, get, put, post) in the http://marklogic.com/rest-api/resource/backupdb namespace
Here's the code for my extension:
xquery version "1.0-ml";
module namespace backupdb =
"http://marklogic.com/rest-api/resource/backupdb";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
declare variable $dbname := "database-backup";
declare variable $s3bucket := "bucket-destination";
declare function backupdb:put(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node()?
{
let $dbname := map:get($params, $dbname)
let $s3bucket := map:get($params, $s3bucket)
xdmp:database-backup(
(:xdmp:database-forests(xdmp:database($dbname)), $s3bucket ):)
xdmp:database-forests(xdmp:database($dbname)), "s3://bucketname/folder" )
(: "s3://s3bucket/folder"); :)
};
Based on the answer from my other question that I got on stackoverflow I figured that I could use parameter and have curl to something like (after successful installation):
curl --anyauth --user "${USER}":"${pass}" -X PUT -d 'undefined' 'http://localhost:8040/v1/resources/backupdb?rs:database-backup=Documents&rs:bucket-destination=s3://bucket/folder'
POST method returns the same error. What am I doing wrong here?
Any suggestions are welcome.
Thank you, Ernest