expand restic commands
This commit is contained in:
parent
47601df5eb
commit
14174a4680
1 changed files with 57 additions and 9 deletions
|
@ -4,9 +4,7 @@ from subprocess import Popen, PIPE
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
run_command(['pwd'])
|
return run_command(['ls', '/backup'])
|
||||||
run_command(['ls', '-l'])
|
|
||||||
run_command(['ls', '/backup'])
|
|
||||||
|
|
||||||
|
|
||||||
def init_repo(repository):
|
def init_repo(repository):
|
||||||
|
@ -14,28 +12,76 @@ def init_repo(repository):
|
||||||
Attempt to initialize the repository.
|
Attempt to initialize the repository.
|
||||||
Doing this after the repository is initialized
|
Doing this after the repository is initialized
|
||||||
"""
|
"""
|
||||||
run_command([
|
return run_command([
|
||||||
"restic",
|
"restic",
|
||||||
|
"--cache-dir",
|
||||||
|
"/restic_cache",
|
||||||
"-r",
|
"-r",
|
||||||
repository,
|
repository,
|
||||||
"init",
|
"init",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def backup_volume(repository, volume):
|
def backup_files(repository, source='/backup'):
|
||||||
run_command([
|
return run_command([
|
||||||
"restic",
|
"restic",
|
||||||
|
"--cache-dir",
|
||||||
|
"/restic_cache",
|
||||||
"-r",
|
"-r",
|
||||||
repository,
|
repository,
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"backup",
|
"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):
|
def snapshots(repository):
|
||||||
run_command([
|
return run_command([
|
||||||
"restic",
|
"restic",
|
||||||
|
"--cache-dir",
|
||||||
|
"/restic_cache",
|
||||||
"-r",
|
"-r",
|
||||||
repository,
|
repository,
|
||||||
"snapshots",
|
"snapshots",
|
||||||
|
@ -43,8 +89,10 @@ def snapshots(repository):
|
||||||
|
|
||||||
|
|
||||||
def check(repository):
|
def check(repository):
|
||||||
run_command([
|
return run_command([
|
||||||
"restic",
|
"restic",
|
||||||
|
"--cache-dir",
|
||||||
|
"/restic_cache",
|
||||||
"-r",
|
"-r",
|
||||||
repository,
|
repository,
|
||||||
"check",
|
"check",
|
||||||
|
|
Loading…
Add table
Reference in a new issue