MarkLogic 7

编程入门 行业动态 更新时间:2024-10-28 15:25:52
本文介绍了MarkLogic 7-使用rest-api的数据库备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望使用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

本文发布于:2023-10-29 03:15:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538554.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MarkLogic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!