Add a type to create a borg repository.
This commit is contained in:
parent
f73bf49e4b
commit
bf5f85068d
7 changed files with 97 additions and 0 deletions
36
type/__borg_repo/gencode-remote
Normal file
36
type/__borg_repo/gencode-remote
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
passphrase=
|
||||||
|
appendonly=
|
||||||
|
|
||||||
|
case "$(cat "${__object:?}/parameter/encryption")" in
|
||||||
|
none)
|
||||||
|
enc=none
|
||||||
|
;;
|
||||||
|
repokey)
|
||||||
|
enc=repokey
|
||||||
|
if [ -f "${__object:?}/parameter/passphrase" ];
|
||||||
|
then
|
||||||
|
passphrase="$(cat "${__object:?}/parameter/passphrase")"
|
||||||
|
else
|
||||||
|
echo "__borg_repo cannot use repokey encryption with no passphrase. Aborting." >&2;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$enc is not a known encryption mode for __borg_repo. Aborting." >&2
|
||||||
|
exit 1;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -f "${__object:?}/parameter/append-only" ];
|
||||||
|
then
|
||||||
|
appendonly='--append-only'
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<- EOF
|
||||||
|
if ! borg check --repository-only 1>&2 2>/dev/null "/${__object_id:?}";
|
||||||
|
then
|
||||||
|
BORG_NEW_PASSPHRASE=$passphrase borg init -e ${enc:?} $appendonly /${__object_id:?}
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
43
type/__borg_repo/man.rst
Normal file
43
type/__borg_repo/man.rst
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
cdist-type__borg_repo(7)
|
||||||
|
========================
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__borg_repo - Configure a borg repository on host
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Initializes a borg repository at the location specified in the
|
||||||
|
`${__object_id}`. Nothing is done if the repository already exists.
|
||||||
|
|
||||||
|
Currently, only `none` and `repokey` are supported as encryption modes;
|
||||||
|
`repokey` requires the `passphrase` argument to be given. The default is
|
||||||
|
`none`.
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
encryption
|
||||||
|
The encryption to use.
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
passphrase
|
||||||
|
The passphrase to encrypt the keyfile with.
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
append-only
|
||||||
|
If the repository is append-only
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
-------
|
||||||
|
Joachim Desroches <joachim.desroches@epfl.ch>
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2020 Joachim Desroches. You can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
14
type/__borg_repo/manifest
Normal file
14
type/__borg_repo/manifest
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
os="$(cat "${__global:?}"/explorer/os)"
|
||||||
|
|
||||||
|
case "$os" in
|
||||||
|
"alpine")
|
||||||
|
borg_package=borgbackup
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "__borg_repo is not yet implemented for os $os. Aborting." >&2;
|
||||||
|
exit 1;
|
||||||
|
esac
|
||||||
|
|
||||||
|
__package "$borg_package"
|
1
type/__borg_repo/parameter/boolean
Normal file
1
type/__borg_repo/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
||||||
|
append-only
|
1
type/__borg_repo/parameter/default/encryption
Normal file
1
type/__borg_repo/parameter/default/encryption
Normal file
|
@ -0,0 +1 @@
|
||||||
|
none
|
1
type/__borg_repo/parameter/optional
Normal file
1
type/__borg_repo/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
passphrase
|
1
type/__borg_repo/parameter/required
Normal file
1
type/__borg_repo/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
encryption
|
Loading…
Reference in a new issue