Commit 6d59ab8e authored by Björn's avatar Björn

adding #11 #12

parent 47fe0fec
## install
# Backup (ALPHA)
Small Wrapper for duplicity. It provides a Config-File and try to simpl
## Install
```bash
apt install duplicity
......@@ -8,6 +12,10 @@ pip3 install paramiko
pip3 install termcolor
```
For sending output through E-Mails, you have to export variables.
**This will be integrated in the next version to .config**
```bash
nano ~/.bash_profile
export SMTP_SERVER=""
......@@ -20,6 +28,50 @@ export SMTP_FROM=""
export SMTP_TO=""
```
## Config
## Commands
### Backup
### Storagebox
If you use a storagebox from Hetzner you can add and remove SSH-Keys with,
```bash
./storagebox.py add
./storagebox.py remove
```
This Script maybe also use for other Servers, but it is original build for the Hetzner
Storagebox.
### Mysql
Exports all Databases of a User.
```bash
./mysql.py all
```
The script uses the same Config-File as **backup.py**.
```bash
[mysql]
username=
password=
target=
```
**username** username for mysql-user
**password** password for mysql-user
**target** path to save files, will create if n
## GPG-Keys
```bash
gpg --list-secret-keys --keyid-format LONG
```
```bash
gpg --import <email>.pub.asc
gpg --edit-key <email>
......@@ -28,7 +80,9 @@ Your decision? 5 (Ultimate trust)
```
```bash
gpg --list-secret-keys --keyid-format LONG
remove_older_than=
remove_all_but_n_full=
remove_all_inc_of_but_n_full=
```
```bash
......@@ -40,10 +94,3 @@ gpg_key_id=
gpg_passphrase=
remove_older_than=s, m, h, D, W, M, Y (seconds, minutes, hours, days, weeks, months, years)
```
```bash_profile
Host 192.168.1.50
HostName 192.168.1.50
IdentityFile ~/.ssh/mcp
IdentitiesOnly yes
```
......@@ -208,7 +208,9 @@ class Backup(Config):
exit()
self._log(process.stdout)
self._log(process.stderr)
if (process.stderr):
self._log(process.stderr)
#
# restore
......@@ -237,7 +239,9 @@ class Backup(Config):
process = self._command(self._gpg_passphrase() + ' duplicity restore ' + self._target() + ' ' + self._args.destination + options)
self._log(process.stdout)
self._log(process.stderr)
if (process.stderr):
self._log(process.stderr)
#
# list current files
......@@ -246,7 +250,9 @@ class Backup(Config):
def _files(self):
process = self._command('duplicity list-current-files ' + self._target())
self._log(process.stdout)
self._log(process.stderr)
if (process.stderr):
self._log(process.stderr)
#
# getting status of collection
......@@ -255,7 +261,9 @@ class Backup(Config):
def _status(self):
process = self._command('duplicity collection-status ' + self._target())
self._log(process.stdout)
self._log(process.stderr)
if (process.stderr):
self._log(process.stderr)
#
# delete old backups files in target,
......@@ -263,13 +271,26 @@ class Backup(Config):
#
#
def _clean(self):
option = None
if (self._config.has_option('default', 'remove_older_than')):
remove_older_than = self._config.get('default', 'remove_older_than')
process = self._command('duplicity remove-older-than ' + remove_older_than + ' --force ' + self._target())
option = 'remove-older-than ' + self._config.get('default', 'remove_older_than')
if (self._config.has_option('default', 'remove_all_but_n_full')):
option = 'remove-all-but-n-full ' + self._config.get('default', 'remove_all_but_n_full')
if (self._config.has_option('default', 'remove_all_inc_of_but_n_full')):
option = 'remove-all-inc-of-but-n-full ' + self._config.get('default', 'remove_all_inc_of_but_n_full')
if (option):
process = self._command('duplicity ' + option + ' --force ' + self._target())
# add log
self._log(process.stdout)
self._log(process.stderr)
if (process.stderr):
self._log(process.stderr)
#
# running command
......
......@@ -53,7 +53,7 @@ class Sendmail:
self._validate_config()
#
# send message
# send message
#
#
def run(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