added dummy servers and repos to aid in automated deployments.

This commit is contained in:
brent s 2019-06-05 23:47:26 -04:00
parent 46113be10f
commit dbc4d6c4b1
4 changed files with 23 additions and 5 deletions

View File

@ -127,6 +127,8 @@ class Backup(object):
for repo in server.findall('{0}repo'.format(self.ns)): for repo in server.findall('{0}repo'.format(self.ns)):
if reponames and repo.attrib['name'] not in reponames: if reponames and repo.attrib['name'] not in reponames:
continue continue
if repo.attrib.get('dummy', 'false').lower()[0] in ('1', 't'):
continue
r = {} r = {}
for a in repo.attrib: for a in repo.attrib:
r[a] = repo.attrib[a] r[a] = repo.attrib[a]
@ -163,6 +165,8 @@ class Backup(object):
if 'all' in self.args['server']: if 'all' in self.args['server']:
self.args['server'] = [] self.args['server'] = []
for server in self.cfg.findall('{0}server'.format(self.ns)): for server in self.cfg.findall('{0}server'.format(self.ns)):
if server.attrib.get('dummy', 'false').lower()[0] in ('1', 't'):
continue
# The server elements are uniquely constrained to the "target" attrib. # The server elements are uniquely constrained to the "target" attrib.
# *NO TWO <server> ELEMENTS WITH THE SAME target= SHOULD EXIST.* # *NO TWO <server> ELEMENTS WITH THE SAME target= SHOULD EXIST.*
self.args['server'].append(server.attrib['target']) self.args['server'].append(server.attrib['target'])
@ -170,6 +174,8 @@ class Backup(object):
sname = server.attrib['target'] sname = server.attrib['target']
if sname not in self.args['server']: if sname not in self.args['server']:
continue continue
if server.attrib.get('dummy', 'false').lower()[0] in ('1', 't'):
continue
self.repos[sname] = {} self.repos[sname] = {}
for x in server.attrib: for x in server.attrib:
if x != 'target': if x != 'target':

View File

@ -93,6 +93,9 @@
be interactively (and securely) prompted for. --> be interactively (and securely) prompted for. -->
<xs:attribute name="password" type="xs:string" use="optional"/> <xs:attribute name="password" type="xs:string" use="optional"/>
<xs:attribute name="compression" type="xs:token" use="optional"/> <xs:attribute name="compression" type="xs:token" use="optional"/>
<!-- This specifies if a repo is a "dummy" configuration.
Useful for testing and placeholder. -->
<xs:attribute name="dummy" type="xs:boolean" use="optional" default="false"/>
</xs:complexType> </xs:complexType>
<xs:unique name="uniquePath"> <xs:unique name="uniquePath">
<xs:selector xpath="borg:path"/> <xs:selector xpath="borg:path"/>
@ -112,6 +115,9 @@
<!-- Only used if "target" is a remote host. --> <!-- Only used if "target" is a remote host. -->
<!-- The remote host SSH user. --> <!-- The remote host SSH user. -->
<xs:attribute name="user" type="borg:posixuser" use="optional"/> <xs:attribute name="user" type="borg:posixuser" use="optional"/>
<!-- This specifies if a server is a "dummy" configuration.
Useful for testing and placeholder. -->
<xs:attribute name="dummy" type="xs:boolean" use="optional" default="false"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<!-- END SERVER --> <!-- END SERVER -->

View File

@ -1,2 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<path>/abc</path> <repo name="testrepo2" password="AnotherSuperSecretPassword" dummy="true">
<path>/dev/null</path>
</repo>

View File

@ -8,20 +8,21 @@
<!-- "target" = either the local filesystem path (absolute or relative to execution) or the remote host <!-- "target" = either the local filesystem path (absolute or relative to execution) or the remote host
"remote" = 1/true if "target" is a remote host or 0/false if it's a local filepath "remote" = 1/true if "target" is a remote host or 0/false if it's a local filepath
"rsh" = (remote host only) the ssh command to use. The default is given below. "rsh" = (remote host only) the ssh command to use. The default is given below.
"user" = (remote host only) the ssh user to use. --> "user" = (remote host only) the ssh user to use.
"dummy" = a boolean; if you need to create a "dummy" server, set this to "true".
It will *not* be parsed or executed upon.
It won't even be created by an init operation or show up in a repolist operation. -->
<server target="fq.dn.tld" remote="true" rsh="ssh -p 22" user="root"> <server target="fq.dn.tld" remote="true" rsh="ssh -p 22" user="root">
<!-- You can (and probably will) have multiple repos for each server. --> <!-- You can (and probably will) have multiple repos for each server. -->
<!-- "name" = the repositoriy name. <!-- "name" = the repositoriy name.
"password" = the repository's password for the key. If not specified, you will be prompted "password" = the repository's password for the key. If not specified, you will be prompted
to enter it interactively and securely. to enter it interactively and securely.
"dummy" = see server[@dummy] explanation.
"compression" = see https://borgbackup.readthedocs.io/en/stable/usage/create.html (-C option) --> "compression" = see https://borgbackup.readthedocs.io/en/stable/usage/create.html (-C option) -->
<repo name="testrepo" password="SuperSecretPassword" compression="lzma,9"> <repo name="testrepo" password="SuperSecretPassword" compression="lzma,9">
<!-- Each path entry is a path to back up. <!-- Each path entry is a path to back up.
See https://borgbackup.readthedocs.io/en/stable/usage/create.html for examples of globbing, etc. --> See https://borgbackup.readthedocs.io/en/stable/usage/create.html for examples of globbing, etc. -->
<path>/a</path> <path>/a</path>
<!-- You can also include other snippets. Either absolute paths, paths relative to your backup.xml file,
or a URL. -->
<xi:include href="sample.config.snippet.xml"/>
<!-- Each exclude entry should be a subdirectory of a <path> (otherwise it wouldn't match, obviously). <!-- Each exclude entry should be a subdirectory of a <path> (otherwise it wouldn't match, obviously).
See https://borgbackup.readthedocs.io/en/stable/usage/create.html for examples of globbing etc. --> See https://borgbackup.readthedocs.io/en/stable/usage/create.html for examples of globbing etc. -->
<exclude>/a/b</exclude> <exclude>/a/b</exclude>
@ -73,5 +74,8 @@
</plugin> </plugin>
</plugins> </plugins>
</repo> </repo>
<!-- You can also include other snippets. Either absolute paths, paths relative to your backup.xml file,
or a URL. -->
<xi:include href="sample.config.snippet.xml"/>
</server> </server>
</borg> </borg>