expand restic commands

This commit is contained in:
Einar Forselv 2019-11-29 01:25:00 +01:00
parent 47601df5eb
commit 14174a4680
1 changed files with 57 additions and 9 deletions

View File

@ -4,9 +4,7 @@ from subprocess import Popen, PIPE
logger = logging.getLogger(__name__)
def test():
run_command(['pwd'])
run_command(['ls', '-l'])
run_command(['ls', '/backup'])
return run_command(['ls', '/backup'])
def init_repo(repository):
@ -14,28 +12,76 @@ def init_repo(repository):
Attempt to initialize the repository.
Doing this after the repository is initialized
"""
run_command([
return run_command([
"restic",
"--cache-dir",
"/restic_cache",
"-r",
repository,
"init",
])
def backup_volume(repository, volume):
run_command([
def backup_files(repository, source='/backup'):
return run_command([
"restic",
"--cache-dir",
"/restic_cache",
"-r",
repository,
"--verbose",
"backup",
volume.destination,
source,
])
def backup_mysql_all(repository, host, port, user, password, filename):
"""Backup all mysql databases"""
# -h host, -p password
return run_command([
'mysqldump',
'--host',
host,
'--port',
port,
'--user',
user,
'--password',
password,
'|',
'restic',
'backup',
'--stdin',
'--stdin-filename',
'dump.sql'
])
def backup_mysql_database(repository, host, port, user, password, filename, database):
"""Backup a single database"""
pass
def mysql_ping(host, port, username, password):
"""Check if the database is up and can be reached"""
return run_command([
'mysqladmin',
'ping',
'--host',
host,
'--port',
port,
'-user',
username,
'--password',
password,
])
def snapshots(repository):
run_command([
return run_command([
"restic",
"--cache-dir",
"/restic_cache",
"-r",
repository,
"snapshots",
@ -43,8 +89,10 @@ def snapshots(repository):
def check(repository):
run_command([
return run_command([
"restic",
"--cache-dir",
"/restic_cache",
"-r",
repository,
"check",