MarkLogic 7-使用rest-api的数据库备份 [英] MarkLogic 7 - database-backup with rest-api

查看:90
本文介绍了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 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"); :)

};

基于我在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'  'http://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-使用rest-api的数据库备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆