Fix commands moved to utils
This commit is contained in:
parent
04bf13ecc4
commit
516117f634
1 changed files with 12 additions and 12 deletions
|
@ -4,7 +4,7 @@ Restic commands
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from restic_compose_backup import commands
|
from restic_compose_backup import utils
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -14,13 +14,13 @@ def init_repo(repository: str):
|
||||||
Attempt to initialize the repository.
|
Attempt to initialize the repository.
|
||||||
Doing this after the repository is initialized
|
Doing this after the repository is initialized
|
||||||
"""
|
"""
|
||||||
return commands.run(restic(repository, [
|
return utils.run(restic(repository, [
|
||||||
"init",
|
"init",
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
def backup_files(repository: str, source='/volumes'):
|
def backup_files(repository: str, source='/volumes'):
|
||||||
return commands.run(restic(repository, [
|
return utils.run(restic(repository, [
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"backup",
|
"backup",
|
||||||
source,
|
source,
|
||||||
|
@ -49,10 +49,10 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
|
||||||
exit_code = 0 if (source_exit == 0 and dest_exit == 0) else 1
|
exit_code = 0 if (source_exit == 0 and dest_exit == 0) else 1
|
||||||
|
|
||||||
if stdout:
|
if stdout:
|
||||||
commands.log_std('stdout', stdout, logging.DEBUG if exit_code == 0 else logging.ERROR)
|
utils.log_std('stdout', stdout, logging.DEBUG if exit_code == 0 else logging.ERROR)
|
||||||
|
|
||||||
if stderr:
|
if stderr:
|
||||||
commands.log_std('stderr', stderr, logging.ERROR)
|
utils.log_std('stderr', stderr, logging.ERROR)
|
||||||
|
|
||||||
return exit_code
|
return exit_code
|
||||||
|
|
||||||
|
@ -62,21 +62,21 @@ def snapshots(repository: str, last=True) -> Tuple[str, str]:
|
||||||
args = ["snapshots"]
|
args = ["snapshots"]
|
||||||
if last:
|
if last:
|
||||||
args.append('--last')
|
args.append('--last')
|
||||||
return commands.run_capture_std(restic(repository, args))
|
return utils.run_capture_std(restic(repository, args))
|
||||||
|
|
||||||
|
|
||||||
def is_initialized(repository: str) -> bool:
|
def is_initialized(repository: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if a repository is initialized using snapshots command.
|
Checks if a repository is initialized using snapshots command.
|
||||||
Note that this cannot separate between uninitalized repo
|
Note that this cannot separate between uninitialized repo
|
||||||
and other errors, but this method is reccomended by the restic
|
and other errors, but this method is recommended by the restic
|
||||||
community.
|
community.
|
||||||
"""
|
"""
|
||||||
return commands.run(restic(repository, ["snapshots", '--last'])) == 0
|
return utils.run(restic(repository, ["snapshots", '--last'])) == 0
|
||||||
|
|
||||||
|
|
||||||
def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str):
|
def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str):
|
||||||
return commands.run(restic(repository, [
|
return utils.run(restic(repository, [
|
||||||
'forget',
|
'forget',
|
||||||
'--group-by',
|
'--group-by',
|
||||||
'paths',
|
'paths',
|
||||||
|
@ -92,13 +92,13 @@ def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str):
|
||||||
|
|
||||||
|
|
||||||
def prune(repository: str):
|
def prune(repository: str):
|
||||||
return commands.run(restic(repository, [
|
return utils.run(restic(repository, [
|
||||||
'prune',
|
'prune',
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
def check(repository: str):
|
def check(repository: str):
|
||||||
return commands.run(restic(repository, [
|
return utils.run(restic(repository, [
|
||||||
"check",
|
"check",
|
||||||
# "--with-cache",
|
# "--with-cache",
|
||||||
]))
|
]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue