Finished backup to swappable implementation

This commit is contained in:
Kevin Veen-Birkenbach 2023-05-02 17:58:16 +02:00
parent 8c04fe88ed
commit 39c7a735a6
17 changed files with 26 additions and 21 deletions

View File

@ -30,7 +30,7 @@ This software allows to setup the docker following applications:
#### Native Applications
This software shipts the following tools which are natively setup on the server:
- [Backups Cleanup](./roles/server_native-backups-cleanup/README.md) - Cleans up old backups
- [Backups Cleanup](./roles/independent_backups-cleanup-timer/README.md) - Cleans up old backups
- [Btrfs Health Check](./roles/server_native-btrfs-health-check/README.md) - Checks the health of Btrfs file systems
- [Docker Health Check](./roles/server_native-docker-health-check/) - Checks the health of docker containers
- [Docker Reverse Proxy](./roles/server_native-docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution

View File

@ -1,3 +1,4 @@
dependencies:
- independent_user-administrator
- independent_systemd-email
- independent_backups-cleanup-service

View File

@ -2,6 +2,7 @@
Description=backing up data
OnFailure=systemd-email@%n.service
ConditionPathExists={{backup_to_swappable_destination_path}}
Wants=backups-cleanup.service
[Service]
Type=oneshot

View File

@ -1,4 +1,4 @@
# role server_native-backups-cleanup
# role independent_backups-cleanup-timer
Cleans up old backups

View File

@ -17,11 +17,10 @@ def is_directory_used_by_another_process(directory_path):
command= "lsof " + directory_path
process = subprocess.Popen([command], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = process.communicate()
if error:
raise Exception(error.strip())
if output:
return True
return False
# @See https://stackoverflow.com/questions/29841984/non-zero-exit-code-for-lsof
if process.wait() > bool(0):
return False
return True
for host_backup_directory_name in os.listdir(args.backups_folder_path):
host_backup_directory_path = os.path.join(args.backups_folder_path, host_backup_directory_name)

View File

@ -4,9 +4,3 @@
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart backups-cleanup.timer"
systemd:
name: backups-cleanup.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -24,9 +24,3 @@
src: "backups-cleanup.service.j2"
dest: "/etc/systemd/system/backups-cleanup.service"
notify: reload backups-cleanup.service
- name: create backups-cleanup.timer
template:
src: "backups-cleanup.timer.j2"
dest: "/etc/systemd/system/backups-cleanup.timer"
notify: restart backups-cleanup.timer

View File

@ -0,0 +1,3 @@
# role independent_backups-cleanup-timer
Timer for cleaning up old backups

View File

@ -0,0 +1,6 @@
- name: "restart backups-cleanup.timer"
systemd:
name: backups-cleanup.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -0,0 +1,2 @@
dependencies:
- independent_backups-cleanup-service

View File

@ -0,0 +1,5 @@
- name: create backups-cleanup.timer
template:
src: "backups-cleanup.timer.j2"
dest: "/etc/systemd/system/backups-cleanup.timer"
notify: restart backups-cleanup.timer

View File

@ -1,4 +1,4 @@
dependencies:
- server_native-git
- independent_systemd-email
- server_native-backups-cleanup
- independent_backups-cleanup-timer

View File

@ -1,3 +1,3 @@
dependencies:
- server_native-backups-provider-user
- server_native-backups-cleanup
- independent_backups-cleanup-timer