49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
Sets up backups to Cloudflare R2
 | 
						|
 | 
						|
# Instalation
 | 
						|
 | 
						|
In requirements.yml:
 | 
						|
 | 
						|
```
 | 
						|
roles:
 | 
						|
  - src: git+https://git.internet-czas-dzialac.pl/kuba/ansible-setup-backups.git
 | 
						|
    version: master
 | 
						|
    name: setup-backups
 | 
						|
```
 | 
						|
 | 
						|
# Setup
 | 
						|
 | 
						|
Create a Cloudflare R2 account and create an admin token.
 | 
						|
 | 
						|
Create a file under `templates/backup-scripts/<hostname>.sh.j2` that
 | 
						|
is a shell script that prepares the data for backup - leave empty if
 | 
						|
not necessary.
 | 
						|
 | 
						|
Then in your playbook run:
 | 
						|
 | 
						|
```yml
 | 
						|
 | 
						|
- name: "Setup backups"
 | 
						|
  hosts: ansible1
 | 
						|
  roles:
 | 
						|
    - setup-backups
 | 
						|
  vars:
 | 
						|
    backup_bucket_prefix: "backup"
 | 
						|
    extra_backup_paths: # most sealcode-roles automatically register their backup dirs in the /backup-dirs txt file, but we can add anything not covered by that here
 | 
						|
      - /var/homebox/data
 | 
						|
    cloudflare_r2_access_key: "cloudflare R2 Access key (for S3-type API)"
 | 
						|
    cloudflare_r2_secret_key: "cloudflare R2 secret key (for S3-type API)"
 | 
						|
    cloudflare_r2_endpoint: https://some_endpoint.r2.cloudflarestorage.com
 | 
						|
    BACKUP_PASSWORD: password
 | 
						|
```
 | 
						|
 | 
						|
 | 
						|
If you are implementing a role that has to register a directory for
 | 
						|
automatic backups, add a task in your role's `tasks/backup.yml`:
 | 
						|
 | 
						|
```yml
 | 
						|
- ansible.builtin.lineinfile:
 | 
						|
    path: "/backup-dirs"
 | 
						|
    line: "{{juice_sqlite_path}}"
 | 
						|
```
 |