dba/databases
library moduleUPR
Summary
Backup operations.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : databases/backups.xqm
Imports
This module is imported by 0 modules. It imports 1 modules.
Variables
Functions
4.1 dba:action
Arities: dba:action#3UP
dba:action
(
$name
as
xs:string
, $info
as
xs:string
, $action
as
function(*)
)
as
empty-sequence()
- name
as
xs:string
database - info
as
xs:string
info string - action
as
function(*)
updating function
empty-sequence()
redirection
Invoked by 0 functions from 0 modules
Annotations
%private | () |
%updating | () |
Source ( 0 lines)
4.2 dba:backup-create
Arities: dba:backup-create#1UR
dba:backup-create
(
$name
as
xs:string
)
as
empty-sequence()
- name
as
xs:string
name of database
empty-sequence()
redirection
Invoked by 0 functions from 0 modules
Annotations
%updating | () |
%rest:GET | () |
%rest:path | ('/dba/backup-create') |
%rest:query-param | ('name','{$name}') |
Source ( 0 lines)
4.3 dba:backup-drop
Arities: dba:backup-drop#2UR
dba:backup-drop
(
$name
as
xs:string
, $backups
as
xs:string*
)
as
empty-sequence()
- name
as
xs:string
name of database - backups
as
xs:string*
backup files
empty-sequence()
redirection
Invoked by 0 functions from 0 modules
Annotations
%updating | () |
%rest:GET | () |
%rest:path | ('/dba/backup-drop') |
%rest:query-param | ('name','{$name}') |
%rest:query-param | ('backup','{$backups}') |
Source ( 0 lines)
4.4 dba:backup-restore
Arities: dba:backup-restore#2UR
dba:backup-restore
(
$name
as
xs:string
, $backup
as
xs:string
)
as
empty-sequence()
- name
as
xs:string
database - backup
as
xs:string
backup file
empty-sequence()
redirection
Invoked by 0 functions from 0 modules
Annotations
%updating | () |
%rest:GET | () |
%rest:path | ('/dba/backup-restore') |
%rest:query-param | ('name','{$name}') |
%rest:query-param | ('backup','{$backup}') |
Source ( 0 lines)
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
ann | http://www.w3.org/2012/xquery |
dba | dba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
rest | http://exquery.org/ns/restxq |
util | dba/util |
6 RestXQ
Paths defined 3.
Path | Method | Function |
---|---|---|
/dba/backup-create | GET | dba:backup-create#1 |
/dba/backup-drop | GET | dba:backup-drop#2 |
/dba/backup-restore | GET | dba:backup-restore#2 |
Source Code
(:~
: Backup operations.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/databases';
import module namespace util = 'dba/util' at '../lib/util.xqm';
(:~ Sub category :)
declare variable $dba:SUB := 'database';
(:~
: Creates a database backup.
: @param $name name of database
: @return redirection
:)
declare
%updating
%rest:GET
%rest:path('/dba/backup-create')
%rest:query-param('name', '{$name}')
function dba:backup-create(
$name as xs:string
) as empty-sequence() {
dba:action($name, 'Backup was created.', function() {
db:create-backup($name)
})
};
(:~
: Drops a database backup.
: @param $name name of database
: @param $backups backup files
: @return redirection
:)
declare
%updating
%rest:GET
%rest:path('/dba/backup-drop')
%rest:query-param('name', '{$name}')
%rest:query-param('backup', '{$backups}')
function dba:backup-drop(
$name as xs:string,
$backups as xs:string*
) as empty-sequence() {
dba:action($name, util:info($backups, 'backup', 'dropped'), function() {
$backups ! db:drop-backup(.)
})
};
(:~
: Restores a database backup.
: @param $name database
: @param $backup backup file
: @return redirection
:)
declare
%updating
%rest:GET
%rest:path('/dba/backup-restore')
%rest:query-param('name', '{$name}')
%rest:query-param('backup', '{$backup}')
function dba:backup-restore(
$name as xs:string,
$backup as xs:string
) as empty-sequence() {
dba:action($name, 'Database was restored.', function() {
db:restore($backup)
})
};
(:~
: Performs a backup operation.
: @param $name database
: @param $info info string
: @param $action updating function
: @return redirection
:)
declare %private %updating function dba:action(
$name as xs:string,
$info as xs:string,
$action as %updating function(*)
) as empty-sequence() {
try {
updating $action(),
util:redirect($dba:SUB, map { 'name': $name, 'info': $info })
} catch * {
util:redirect($dba:SUB, map { 'name': $name, 'error': $err:description })
}
};