multiple sources for multiple hosts #297
Replies: 3 comments 3 replies
-
Hi! Unfortunately there's no one size fits all configuration. But since we got a few similar questions recently I think we should provide a few use cases in the documentation. My own configurations are generated for each server from an ansible template. This is something I could document though. In the meantime have you find any interesting information from the other discussion #275? |
Beta Was this translation helpful? Give feedback.
-
As a possible answer to your 2 main challenges:
E.g.: # yaml-language-server: $schema=https://creativeprojects.github.io/resticprofile/jsonschema/config-2.json
version: "2"
##
# {{ $HostsWithLocalBase := list "hosta" "hostb" "hostc" }}
##
# {{ $Hostname := printf "/%s/" ( .Hostname | lower ) }}
# {{ $IsLocalBase := printf "/%s/" ( $HostsWithLocalBase | join "/" | lower ) | contains $Hostname }}
# {{ $Base := "base-sftp" }}
# {{ if $IsLocalBase }}{{ $Base = "base-local" }}{{ end }}
##
# Hosts with base-local: [ {{ $HostsWithLocalBase | join ", " }} ]
# Host {{ $Hostname }} uses {{ $Base }}
##
profiles:
# defaults for all
default:
initialize: true
base-sftp:
inherit: "default"
repository: "sftp://..."
password-file: ""
base-local:
inherit: "default"
repository: "file:/path/to/repo"
password-file: ""
backup-xyz:
inherit: "{{ $Base }}"
backup:
source: ...
backup-mysql:
inherit: "{{ $Base }}"
backup:
stdin-command: "cat /etc/mysql/backup-password.txt | mysqldump --all-databases --order-by-primary --password"
stdin-filename: "dump.sql" Resulting in:
References: |
Beta Was this translation helpful? Give feedback.
-
Thanks, I will give it a go when I have some time available. For now I have redone my batch file to use restic instead of rsync using my faithful batch file and command line parameters. I'm not a programmer (just a hobbyist with a few servers that need backing up), so it always takes a while for me to digest new stuff. |
Beta Was this translation helpful? Give feedback.
-
Currently, I'm using a generic bash script that, depending on the host, has different backup options, such as: backup /etc, /home, docker or mysql. One script to rule them all ;-)
I'm new to restic and resticprofiles, and am charmed by it. And I have done a few tests, but I can't seem to get my head around the way to implement this in a single profile yaml file.
I can call a group, to go through certain backups, such as backing up crontab through stdin, backing up sql trough sdtin, or regular file backups. So it will iterate through the list to backup just fine.
So I have two main challenges:
I know I can create a different yaml file for every single host I have, but then I struggle with keeping the backups and rules consistent on all hosts. I prefer to have a single script for all hosts and all types of backups.
I know I can use mixins, but fail to see a way to use this based on the hostname of the server to backup.
Any ideas or suggestions ? thx
Beta Was this translation helpful? Give feedback.
All reactions