Add OneLab Helm chart, Argo CD Application, and GitOps values for k3s
Made-with: Cursor
This commit is contained in:
37
app/playbooks/tasks/backup-task.yml
Normal file
37
app/playbooks/tasks/backup-task.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Checking if OneLab is running
|
||||
shell: docker stack ls | grep 'onelab' | grep -v 'onelab_proxy' | wc -l
|
||||
become: true
|
||||
register: backup_stack_count
|
||||
|
||||
# Start DB if OneLab is not running
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/start-db-only.yml"
|
||||
when: backup_stack_count.stdout == "0"
|
||||
|
||||
- name: Creating backup directory
|
||||
file:
|
||||
path: "{{ onelab_path }}/backups/{{ ansible_date_time.iso8601_basic_short }}_1.27.0"
|
||||
state: directory
|
||||
register: backup_path
|
||||
|
||||
- name: Backing up files
|
||||
shell:
|
||||
tar --exclude='temp' -czvf {{ backup_path.path }}/onelab.tar.gz -C {{ onelab_path }} ./data ./installation ./nginx ./proxy ./rabbit ./ssl ./backup.sh ./configurations.yml ./docker-compose.yml ./reconfigure.sh ./start.sh ./stop.sh ./update.sh
|
||||
become: yes
|
||||
|
||||
- name: Backing up database
|
||||
shell:
|
||||
docker exec -i $(docker ps --filter "name=onelab_db|onelab-db" -q) pg_dump -Upostgres -Fc > {{ backup_path.path }}/db.tar.gz
|
||||
become: yes
|
||||
|
||||
- name: Creating restore script files
|
||||
copy:
|
||||
src: "{{ onelab_path }}/installation/latest/resources/restore/{{ item }}"
|
||||
dest: "{{ backup_path.path }}"
|
||||
with_items:
|
||||
- 'restore.yml'
|
||||
- 'restore.sh'
|
||||
|
||||
# Stop DB if OneLab was not running
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/stop-db-only.yml"
|
||||
when: backup_stack_count.stdout == "0"
|
||||
Reference in New Issue
Block a user