mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-12-23 02:45:02 +01:00
Renamed to backup-docker
This commit is contained in:
parent
83c93be87f
commit
0d4eb75afe
@ -34,7 +34,7 @@ This software shipts the following tools which are natively setup on the server:
|
||||
- [Btrfs Health Check](./roles/health-btrfs/README.md) - Checks the health of Btrfs file systems
|
||||
- [Docker Health Check](./roles/health-docker/) - Checks the health of docker containers
|
||||
- [Docker Reverse Proxy](./roles/docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution
|
||||
- [Docker Volume Backup](./roles/docker-volume-backup/) - Backup Solution for Docker Volumes
|
||||
- [Docker Volume Backup](./roles/backup-docker/) - Backup Solution for Docker Volumes
|
||||
- [Pull Primary Backups](./roles/backups-consumer/README.md) - Pulls the backups from another server and stores them
|
||||
- [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn
|
||||
|
||||
|
3
roles/backup-docker-cleanup/README.md
Normal file
3
roles/backup-docker-cleanup/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Docker Volume Backup Cleanup
|
||||
This script cleans up failed docker backups.
|
||||
It uses https://github.com/kevinveenbirkenbach/backup-docker-cleanup as base.
|
5
roles/backup-docker-cleanup/handlers/main.yml
Normal file
5
roles/backup-docker-cleanup/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
- name: "reload backup-docker-cleanup.service daemon"
|
||||
systemd:
|
||||
name: backup-docker-cleanup.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
18
roles/backup-docker-cleanup/tasks/main.yml
Normal file
18
roles/backup-docker-cleanup/tasks/main.yml
Normal file
@ -0,0 +1,18 @@
|
||||
- name: pull backup-docker-cleanup.git
|
||||
git:
|
||||
repo: "https://github.com/kevinveenbirkenbach/backup-docker-cleanup.git"
|
||||
dest: "{{docker_volume_backup_cleanup_folder}}"
|
||||
update: yes
|
||||
register: git_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Warn if repo is not reachable
|
||||
debug:
|
||||
msg: "Warning: Repository is not reachable."
|
||||
when: git_result.failed
|
||||
|
||||
- name: configure backup-docker-cleanup.service
|
||||
template:
|
||||
src: backup-docker-cleanup.service.j2
|
||||
dest: /etc/systemd/system/backup-docker-cleanup.service
|
||||
notify: reload backup-docker-cleanup.service daemon
|
@ -1 +1 @@
|
||||
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}docker-volume-backup-cleanup/"
|
||||
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}backup-docker-cleanup/"
|
12
roles/backup-docker/handlers/main.yml
Normal file
12
roles/backup-docker/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
||||
- name: "reload backup-docker.service"
|
||||
systemd:
|
||||
name: backup-docker.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
|
||||
- name: "restart backup-docker.timer"
|
||||
systemd:
|
||||
name: backup-docker.timer
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
@ -2,4 +2,4 @@ dependencies:
|
||||
- git
|
||||
- backups-provider
|
||||
- systemd_notifier
|
||||
- docker-volume-backup-cleanup
|
||||
- backup-docker-cleanup
|
@ -5,9 +5,9 @@
|
||||
- python-pandas
|
||||
state: present
|
||||
|
||||
- name: pull docker-volume-backup.git
|
||||
- name: pull backup-docker.git
|
||||
git:
|
||||
repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup.git"
|
||||
repo: "https://github.com/kevinveenbirkenbach/backup-docker.git"
|
||||
dest: "{{docker_volume_backup_folder}}"
|
||||
update: yes
|
||||
register: git_result
|
||||
@ -18,15 +18,15 @@
|
||||
msg: "Warning: Repository is not reachable."
|
||||
when: git_result.failed
|
||||
|
||||
- name: configure docker-volume-backup.service
|
||||
- name: configure backup-docker.service
|
||||
template:
|
||||
src: docker-volume-backup.service.j2
|
||||
dest: /etc/systemd/system/docker-volume-backup.service
|
||||
notify: reload docker-volume-backup.service
|
||||
src: backup-docker.service.j2
|
||||
dest: /etc/systemd/system/backup-docker.service
|
||||
notify: reload backup-docker.service
|
||||
|
||||
- name: configure docker-volume-backup.timer.tpl
|
||||
template: src=docker-volume-backup.timer.j2 dest=/etc/systemd/system/docker-volume-backup.timer
|
||||
notify: restart docker-volume-backup.timer
|
||||
- name: configure backup-docker.timer.tpl
|
||||
template: src=backup-docker.timer.j2 dest=/etc/systemd/system/backup-docker.timer
|
||||
notify: restart backup-docker.timer
|
||||
|
||||
- name: create {{docker_volume_backup_folder}}databases.csv
|
||||
copy:
|
7
roles/backup-docker/templates/backup-docker.service.j2
Normal file
7
roles/backup-docker/templates/backup-docker.service.j2
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=docker volume backup
|
||||
OnFailure=systemd-notifier@%n.service backup-docker-cleanup.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker.py
|
1
roles/backup-docker/vars/main.yml
Normal file
1
roles/backup-docker/vars/main.yml
Normal file
@ -0,0 +1 @@
|
||||
docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker/"
|
@ -2,4 +2,4 @@ dependencies:
|
||||
- git
|
||||
- systemd_notifier
|
||||
- backups-cleanup-timer
|
||||
- docker-volume-backup-cleanup
|
||||
- backup-docker-cleanup
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=pull remote backups
|
||||
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
|
||||
OnFailure=systemd-notifier@%n.service backup-docker-cleanup.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
@ -12,8 +12,8 @@ hashed_machine_id="$($get_hashed_machine_id | head -c 64)"
|
||||
get_backup_types="find /Backups/$hashed_machine_id/ -maxdepth 1 -type d -execdir basename {} ;";
|
||||
|
||||
|
||||
# @todo This configuration is not scalable yet. If other backup services then docker-volume-backup are integrated, this logic needs to be optimized
|
||||
get_version_directories="ls -d /Backups/$hashed_machine_id/docker-volume-backup/*"
|
||||
# @todo This configuration is not scalable yet. If other backup services then backup-docker are integrated, this logic needs to be optimized
|
||||
get_version_directories="ls -d /Backups/$hashed_machine_id/backup-docker/*"
|
||||
last_version_directory="$($get_version_directories | tail -1)"
|
||||
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/"
|
||||
|
||||
|
@ -81,7 +81,7 @@ docker-compose build &&
|
||||
docker-compose -p akaunting up -d --force-recreate
|
||||
|
||||
# recover all volumes
|
||||
cd {{path_administrator_scripts}}docker-volume-backup &&
|
||||
cd {{path_administrator_scripts}}backup-docker &&
|
||||
bash docker-volume-recover.sh akaunting_akaunting-modules ${machine_id:0:64} "$backup_version" &&
|
||||
bash docker-volume-recover.sh akaunting_akaunting-data ${machine_id:0:64} "$backup_version" &&
|
||||
bash docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting
|
||||
|
@ -30,7 +30,7 @@ waiting_time=600
|
||||
blocker_running=True
|
||||
while blocker_running:
|
||||
try:
|
||||
bash("systemctl is-active --quiet docker-volume-backup.service")
|
||||
bash("systemctl is-active --quiet backup-docker.service")
|
||||
bash("systemctl is-active --quiet update-docker.service")
|
||||
print("backup is running.")
|
||||
print("trying again in " + str(waiting_time) + " seconds.")
|
||||
|
@ -59,8 +59,8 @@ and disable the not functioning apps.
|
||||
```bash
|
||||
cd {{path_docker_compose_files}}nextcloud &&
|
||||
docker-compose down &&
|
||||
docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/docker-volume-backup/latest/nextcloud_database/sql/backup.sql" &&
|
||||
cd {{path_administrator_scripts}}docker-volume-backup &&
|
||||
docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/backup-docker/latest/nextcloud_database/sql/backup.sql" &&
|
||||
cd {{path_administrator_scripts}}backup-docker &&
|
||||
bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)"
|
||||
```
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Docker Volume Backup Cleanup
|
||||
This script cleans up failed docker backups.
|
||||
It uses https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup as base.
|
@ -1,5 +0,0 @@
|
||||
- name: "reload docker-volume-backup-cleanup.service daemon"
|
||||
systemd:
|
||||
name: docker-volume-backup-cleanup.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
@ -1,18 +0,0 @@
|
||||
- name: pull docker-volume-backup-cleanup.git
|
||||
git:
|
||||
repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup.git"
|
||||
dest: "{{docker_volume_backup_cleanup_folder}}"
|
||||
update: yes
|
||||
register: git_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Warn if repo is not reachable
|
||||
debug:
|
||||
msg: "Warning: Repository is not reachable."
|
||||
when: git_result.failed
|
||||
|
||||
- name: configure docker-volume-backup-cleanup.service
|
||||
template:
|
||||
src: docker-volume-backup-cleanup.service.j2
|
||||
dest: /etc/systemd/system/docker-volume-backup-cleanup.service
|
||||
notify: reload docker-volume-backup-cleanup.service daemon
|
@ -1,12 +0,0 @@
|
||||
- name: "reload docker-volume-backup.service"
|
||||
systemd:
|
||||
name: docker-volume-backup.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
|
||||
- name: "restart docker-volume-backup.timer"
|
||||
systemd:
|
||||
name: docker-volume-backup.timer
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
@ -1,7 +0,0 @@
|
||||
[Unit]
|
||||
Description=docker volume backup
|
||||
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python {{docker_volume_backup_folder}}docker-volume-backup.py
|
@ -1 +0,0 @@
|
||||
docker_volume_backup_folder: "{{path_administrator_scripts}}docker-volume-backup/"
|
@ -1,5 +1,5 @@
|
||||
dependencies:
|
||||
- docker-volume-backup
|
||||
- backup-docker
|
||||
- user-administrator
|
||||
- health-docker
|
||||
- docker-compose-restart-unhealthy
|
||||
|
Loading…
Reference in New Issue
Block a user