我希望使用rest-api自动执行ML7中的备份. 由于没有开箱即用的功能,因此我认为可以按需要的时间表使用curl命令添加新的扩展程序和设置脚本. 听起来很简单,但是由于某些原因,当我尝试安装扩展程序时,它会吐出无效内容"并显示日志:
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 marklogic/rest-api/resource/backupdb namespace
这是我的扩展程序的代码:
Here's the code for my extension:
xquery version "1.0-ml"; module namespace backupdb = "marklogic/rest-api/resource/backupdb"; import module namespace admin = "marklogic/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"); :) };基于我在stackoverflow上遇到的另一个问题的答案,我发现我可以使用参数并且可以卷曲到类似的东西(成功安装后):
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' 'localhost:8040/v1/resources/backupdb?rs:database-backup=Documents&rs:bucket-destination=s3://bucket/folder'POST方法返回相同的错误. 我在这里做什么错了?
POST method returns the same error. What am I doing wrong here?
欢迎提出任何建议.
谢谢你, 欧内斯特
推荐答案此外,您的函数中有语法错误(在FLWOR中缺少返回值),因此不需要导入管理库.
Also, you have a syntax error in your function (missing a return in the FLWOR) and you do not need to import the Admin library.
更多推荐
MarkLogic 7
发布评论