$darkmode
Elektra 0.11.0
kdb-cp(1) -- Copy keys within the key database

SYNOPSIS

kdb cp <source> <dest>

DESCRIPTION

This command copies key(s) in the Key database. You can copy keys to another directory within the database or even below another key. Note that you cannot copy a key below itself.

The argument source is the path of the key(s) you want to copy and dest is the path where you would like to copy the key(s) to. Note that when using the -r flag, source as well as all the keys below will be copied.

LIMITATIONS

Neither source nor dest can be a cascading key. (Start with /). Make sure to select a namespace.

RETURN VALUES

This command will return the following values as an exit status:

OPTIONS

EXAMPLES

1 # Backup-and-Restore: user:/tests/cp/examples
2 
3 # Create the keys we use for the examples
4 kdb set user:/tests/cp/examples/kdb-cp/key key1
5 kdb set user:/tests/cp/examples/kdb-cp/key/first key
6 kdb set user:/tests/cp/examples/kdb-cp/key/second key
7 kdb set user:/tests/cp/examples/kdb-cp/cpkey key1
8 kdb set user:/tests/cp/examples/kdb-cp/cpkey/first key
9 kdb set user:/tests/cp/examples/kdb-cp/cpkey/second key
10 kdb set user:/tests/cp/examples/kdb-cp/cpkeyerror/first key
11 kdb set user:/tests/cp/examples/kdb-cp/cpkeyerror/second anotherValue
12 kdb set user:/tests/cp/examples/kdb-cp/another/key one
13 kdb set user:/tests/cp/examples/kdb-cp/another/value two
14 
15 # To copy a single key:
16 kdb cp user:/tests/cp/examples/kdb-cp/key user:/tests/cp/examples/kdb-cp/key2
17 #>
18 
19 # To copy multiple keys:
20 kdb cp -r user:/tests/cp/examples/kdb-cp/key user:/tests/cp/examples/kdb-cp/copied
21 #>
22 
23 # If the target-key already exists and has a different value, cp fails:
24 kdb cp -r user:/tests/cp/examples/kdb-cp/key user:/tests/cp/examples/kdb-cp/cpkeyerror
25 # RET: 11
26 
27 # If the target-key already exists and has the same value as the source, everything is fine:
28 kdb cp -r user:/tests/cp/examples/kdb-cp/key user:/tests/cp/examples/kdb-cp/cpkey
29 #>
30 
31 # To force the copy of keys:
32 kdb cp -rf user:/tests/cp/examples/kdb-cp/key user:/tests/cp/examples/kdb-cp/cpkeyerror
33 #>
34 
35 # Now the key-values of /cpkeyerror are overwritten:
36 kdb export user:/tests/cp/examples/kdb-cp/cpkeyerror mini
37 #> =key1
38 #> first=key
39 #> second=key
40 
41 # To copy keys below an existing key:
42 kdb cp -r user:/tests/cp/examples/kdb-cp/another user:/tests/cp/examples/kdb-cp/another/key
43 #>
44 
45 kdb rm -r user:/tests/cp/examples/kdb-cp/