rsync exit codes to fail backup
This commit is contained in:
@@ -7,7 +7,7 @@ import sys
|
|||||||
import shlex
|
import shlex
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
VERSION = "1.0"
|
VERSION = "1.1"
|
||||||
|
|
||||||
|
|
||||||
class RSB:
|
class RSB:
|
||||||
@@ -25,8 +25,12 @@ class RSB:
|
|||||||
self.folder_format = "backup-%Y%m%d-%H%M%S"
|
self.folder_format = "backup-%Y%m%d-%H%M%S"
|
||||||
os.makedirs(self.current, exist_ok=True)
|
os.makedirs(self.current, exist_ok=True)
|
||||||
self.clean_old()
|
self.clean_old()
|
||||||
self.make_backup()
|
success = self.make_backup()
|
||||||
|
if success:
|
||||||
self.make_hardlinks()
|
self.make_hardlinks()
|
||||||
|
else:
|
||||||
|
print("Program exited with errors")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def diskused(self):
|
def diskused(self):
|
||||||
"""in percents"""
|
"""in percents"""
|
||||||
@@ -40,7 +44,13 @@ class RSB:
|
|||||||
return pcent
|
return pcent
|
||||||
|
|
||||||
def clean_old(self):
|
def clean_old(self):
|
||||||
print("Cleaning old backups")
|
print("Cleaning old backup")
|
||||||
|
if self.delete_older:
|
||||||
|
print("Keeping newer than {:} days".format(self.delete_older))
|
||||||
|
if self.keep_n:
|
||||||
|
print("Keep at most {:} backups".format(self.keep_n))
|
||||||
|
if self.delete_disk_percentage:
|
||||||
|
print("Keep until disk is {:}% full".format(self.delete_disk_percentage))
|
||||||
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
dirs = [
|
dirs = [
|
||||||
@@ -93,7 +103,9 @@ class RSB:
|
|||||||
self.current,
|
self.current,
|
||||||
]
|
]
|
||||||
print(command)
|
print(command)
|
||||||
subprocess.call(command, shell=False)
|
exitcode = subprocess.call(command, shell=False)
|
||||||
|
success = exitcode in (0, 23, 24, 25)
|
||||||
|
return success
|
||||||
|
|
||||||
|
|
||||||
def get_opts():
|
def get_opts():
|
||||||
|
|||||||
Reference in New Issue
Block a user