Commit 5d1ed6cc authored by Björn's avatar Björn

adding

parent bac22d06
targets=
work_directory=
remote_username=
remote_host=
[default]
targets = test,g
work_directory = build
#gpg_key_id =
#mysql_password=
#mysql_username=
#remote_port=
#remote_directory=
#gpg_key_id=
#max_age=
#chunk_size=
#prefix=
#excludes=
\ No newline at end of file
[remote]
#remote_username =
#remote_host =
#remote_port =
#remote_directory =
[mysql]
#mysql_password =
#mysql_username =
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: tock not found
Error: "tock" not found!
Error: "tock" not found!
Error: "g" not found!
Error: "tock" not found!
Error: "g" not found!
Error: "tock" not found!
Error: "g" not found!
#!/usr/bin/python3
#
# sending email
#
# usage: backup.py [-h] [--attachments ATTACHMENTS [ATTACHMENTS ...]]
# [--encrypt ENCRYPT]
# message subject
#
# install to use:
#
# pip3 install python-gnupg
# pip3 install configparser
#
import argparse
import configparser
import os
import io
#
#
#
#
class BackupFiles:
#
#
#
#
def __init__(self):
# adding parser for arguments
parser = argparse.ArgumentParser()
# define arguments
parser.add_argument('command', help='backup|restore')
parser.add_argument('config', help='full path of config-file')
self._args = parser.parse_args()
self._config = configparser.RawConfigParser(allow_no_value=True)
self._config.read_file(open(self._args.config))
#
# adding message to log-file
#
#
def _log(self, message):
with open('01_01_2002.log', 'a') as f:
print(message, file=f)
#
# generate string for source and adding all
#
#
def _includes(self):
includes = ''
sources = self._config.get('default', 'sources')
sources = sources.split(',')
# adding includes to duplicity
for source in sources:
if (os.path.exists(source)):
if (len(includes) > 0):
includes =+ '--include ' + source
else:
includes = source
else:
self._log('Error: "' + source + '" not found!')
# if includes is empty
if (includes == ''):
print('Error: no sources are found!')
exit()
return includes
#
# generate string for source and adding all
#
#
def _gpg_key_id(self):
return '--encrypt-key=' + self._config.get('default', 'gpg_key_id')
#
# start backup
#
#
def _backup(self):
target = self._config.get('default', 'target')
includes = self._includes()
gpg_key_id = self._gpg_key_id()
os.system("duplicity full " + includes + " " + gpg_key_id + " " + target)
#
#
#
#
def _restore(self):
target = self._config.get('default', 'target')
os.system("duplicity restore " + target)
#
# delete old backups files in target,
# only runs if max_age is set
#
#
def _clean(self):
if (self._config.get('default', 'max_age')):
max_age = self._config.get('default', 'max_age')
target = self._config.get('default', 'target')
os.system("duplicity remove-older-than " + max_age + " --force " + target)
#
#
#
#
def run(self):
if (self._args.command == 'backup'):
self._backup()
elif: (self._args.command == 'restore'):
self._restore()
self._clean()
# let it rain
backup = BackupFiles()
backup.run()
#
#
#
#
class Duplicity:
#
#
#
#
def __init__(self):
#
#
#
#
def _backup(self):
#
#
#
#
def _restore(self):
#
#
#
#
#
class Config:
#
#
#
#
def __init__(self):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment