[fix] the management station should work
This commit is contained in:
		
							parent
							
								
									23609395dc
								
							
						
					
					
						commit
						5ac24196dc
					
				| @ -2,7 +2,7 @@ | ||||
| 
 | ||||
| - name: management | get key file | ||||
|   fetch:  | ||||
|        src: "~{{ borgbackup_client_user}}/.config/borg/keys/{{ borgbackup_management_key_name }}{{ inventory_hostname }}"  | ||||
|        src: ~{{ borgbackup_client_user}}/.config/borg/keys/{{ borgbackup_management_key_name }}{{ inventory_hostname | regex_replace('\.','_')}} | ||||
|        dest: /tmp/.borgbackup_key_{{ inventory_hostname }} | ||||
|        flat: yes | ||||
|   changed_when: false | ||||
|  | ||||
| @ -1,4 +1,20 @@ | ||||
| --- | ||||
| - name: management | create scripts dir | ||||
|   file: | ||||
|     path: "~{{ borgbackup_management_user }}/prune.d" | ||||
|     state: "directory" | ||||
|     owner: "{{ borgbackup_management_user }}" | ||||
|     group: "{{ borgbackup_management_user }}" | ||||
|     mode: "0770" | ||||
| 
 | ||||
| - name: management | create logs dir | ||||
|   file: | ||||
|     path: "/var/log/borgbackup-prune" | ||||
|     state: "directory" | ||||
|     owner: "{{ borgbackup_management_user }}" | ||||
|     group: "{{ borgbackup_management_user }}" | ||||
|     mode: "0770" | ||||
| 
 | ||||
| - name: management | put management station prune script | ||||
|   template: | ||||
|     src: prune.sh.j2 | ||||
| @ -7,6 +23,19 @@ | ||||
|     group: "{{ borgbackup_management_user }}" | ||||
|     mode: 0700 | ||||
| 
 | ||||
| - name: management | put each host prune script  | ||||
|   template: | ||||
|     src: prune.host.sh.j2 | ||||
|     dest: "~{{ borgbackup_management_user }}/prune.d/{{item}}" | ||||
|     owner: "{{ borgbackup_management_user }}" | ||||
|     group: "{{ borgbackup_management_user }}" | ||||
|     mode: 0770 | ||||
|   delegate_to: "secure" | ||||
|   when:  item != borgbackup_management_station and item not in groups['borgbackup_servers'] | ||||
|   with_items: "{{ play_hosts }}" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| - name: management | put management sshpubkey on the normal backupserver | ||||
|   authorized_key: | ||||
|     user: "{{ item.user }}" | ||||
|  | ||||
							
								
								
									
										12
									
								
								templates/prune.host.sh.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								templates/prune.host.sh.j2
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| #! /bin/bash | ||||
| echo "Host: {{ item }}" | ||||
| export BORG_PASSPHRASE={{ hostvars[item].borgbackup_passphrase }} | ||||
| {% for b in borgbackup_servers %} | ||||
| {% if b.type == 'hetzner' %} | ||||
| REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ item }} | ||||
| {% else %} | ||||
| REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ item }} | ||||
| {% endif %} | ||||
| /usr/local/bin/borg prune -v $REPOSITORY {{ b.options }} -H {{ borgbackup_retention.hourly }} -d {{ borgbackup_retention.daily }} -w {{ borgbackup_retention.weekly }} -m {{ borgbackup_retention.monthly }} -y {{ borgbackup_retention.yearly }} | ||||
| dzadza | ||||
| {% endfor %} | ||||
| @ -16,20 +16,5 @@ LOG_DIR=/var/log/borgbackup | ||||
| LOG_FILE=/var/log/borgbackup-prune/${DATE}.log | ||||
| exec &> >(tee "$LOG_FILE") | ||||
| 
 | ||||
| {% for h in groups['all'] %} | ||||
|   {% if h != borgbackup_management_station and h not in groups['borgbackup_servers'] -%}  | ||||
| echo "Host: {{ h }}" | ||||
| export BORG_PASSPHRASE={{ hostvars[h].borgbackup_passphrase }} | ||||
|     {% if borgbackup_management_station is defined and inventory_hostname == borgbackup_management_station %} | ||||
|       {% for b in borgbackup_servers %} | ||||
|         {% if b.type == 'hetzner' %} | ||||
| REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ h }} | ||||
|         {% else %} | ||||
| REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ h }} | ||||
|         {% endif %} | ||||
| /usr/local/bin/borg prune -v $REPOSITORY {{ b.options }} -H {{ borgbackup_retention.hourly }} -d {{ borgbackup_retention.daily }} -w {{ borgbackup_retention.weekly }} -m {{ borgbackup_retention.monthly }} -y {{ borgbackup_retention.yearly }} | ||||
| run-parts --lsbsysinit ~{{ borgbackup_management_user }}/prune.d | ||||
| 
 | ||||
|       {% endfor %} | ||||
|     {% endif %} | ||||
|   {% endif %} | ||||
| {% endfor %} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user