rsync exit codes to fail backup
This commit is contained in:
@@ -7,7 +7,7 @@ import sys
|
||||
import shlex
|
||||
from argparse import ArgumentParser
|
||||
|
||||
VERSION = "1.0"
|
||||
VERSION = "1.1"
|
||||
|
||||
|
||||
class RSB:
|
||||
@@ -25,8 +25,12 @@ class RSB:
|
||||
self.folder_format = "backup-%Y%m%d-%H%M%S"
|
||||
os.makedirs(self.current, exist_ok=True)
|
||||
self.clean_old()
|
||||
self.make_backup()
|
||||
success = self.make_backup()
|
||||
if success:
|
||||
self.make_hardlinks()
|
||||
else:
|
||||
print("Program exited with errors")
|
||||
sys.exit(1)
|
||||
|
||||
def diskused(self):
|
||||
"""in percents"""
|
||||
@@ -40,7 +44,13 @@ class RSB:
|
||||
return pcent
|
||||
|
||||
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()
|
||||
dirs = [
|
||||
@@ -93,7 +103,9 @@ class RSB:
|
||||
self.current,
|
||||
]
|
||||
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():
|
||||
|
||||
Reference in New Issue
Block a user