Finished backup to swappable implementation

This commit is contained in:
Kevin Veen-Birkenbach 2023-05-02 17:58:16 +02:00
parent cdf0f30a76
commit 1b4d726fd0
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 #### Native Applications
This software shipts the following tools which are natively setup on the server: 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 - [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 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 - [Docker Reverse Proxy](./roles/server_native-docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution

View File

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

View File

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

View File

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

View File

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

View File

@ -4,9 +4,3 @@
state: reloaded state: reloaded
enabled: yes enabled: yes
daemon_reload: 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" src: "backups-cleanup.service.j2"
dest: "/etc/systemd/system/backups-cleanup.service" dest: "/etc/systemd/system/backups-cleanup.service"
notify: reload 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: dependencies:
- server_native-git - server_native-git
- independent_systemd-email - independent_systemd-email
- server_native-backups-cleanup - independent_backups-cleanup-timer

View File

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