mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-23 05:01:04 +01:00
Optimized local backup code
This commit is contained in:
parent
f31151fb1a
commit
d243b6a32b
@ -46,15 +46,17 @@ def main():
|
|||||||
]
|
]
|
||||||
rsync_output = subprocess.check_output(rsync_command, stderr=subprocess.STDOUT, text=True)
|
rsync_output = subprocess.check_output(rsync_command, stderr=subprocess.STDOUT, text=True)
|
||||||
|
|
||||||
if "rsync warning: some files vanished before they could be transferred" in rsync_output:
|
print(rsync_output)
|
||||||
|
print("Synchronization finished")
|
||||||
|
sys.exit(0)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(e.output)
|
||||||
|
if "rsync warning: some files vanished before they could be transferred" in e.output:
|
||||||
print("Synchronization finished with rsync warning")
|
print("Synchronization finished with rsync warning")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print("Synchronization finished")
|
print("Synchronization failed")
|
||||||
sys.exit(0)
|
sys.exit(1)
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print("Synchronization failed:", e.output)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
@ -1,13 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup to USB when mounted to {{ backup_to_usb_mount }}
|
Description=Backup to USB when mounted to {{ backup_to_usb_mount }}
|
||||||
Wants={{systemctl_mount_service_name}}
|
Wants={{systemctl_mount_service_name}}
|
||||||
After={{systemctl_mount_service_name}}
|
|
||||||
OnFailure=systemd-notifier@%n.service
|
OnFailure=systemd-notifier@%n.service
|
||||||
Requires=backups-cleanup.service
|
|
||||||
After=backups-cleanup.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}}
|
ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}}
|
||||||
|
ExecStartPost=/bin/systemctl start backups-cleanup.service
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user