mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-09-28 06:35:24 +00:00
52 lines
842 B
Python
52 lines
842 B
Python
import os
|
|
from subprocess import Popen, PIPE, check_call
|
|
|
|
|
|
def init_repo(repository):
|
|
run_command([
|
|
"restic",
|
|
"-r",
|
|
repository,
|
|
"init",
|
|
])
|
|
|
|
|
|
def backup_volume(repository, volume):
|
|
run_command([
|
|
"restic",
|
|
"-r",
|
|
repository,
|
|
"--verbose",
|
|
"backup",
|
|
volume.destination,
|
|
])
|
|
|
|
|
|
def snapshots(repository):
|
|
run_command([
|
|
"restic",
|
|
"-r",
|
|
repository,
|
|
"snapshots",
|
|
])
|
|
|
|
|
|
def check(repository):
|
|
run_command([
|
|
"restic",
|
|
"-r",
|
|
repository,
|
|
"check",
|
|
])
|
|
|
|
|
|
def run_command(cmd):
|
|
child = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
|
stdoutdata, stderrdata = child.communicate()
|
|
|
|
if stdoutdata:
|
|
print(stdoutdata.decode())
|
|
|
|
if stderrdata:
|
|
print(stderrdata.decode())
|