borgbase / ansible-role-borgbackup

Ansible role to set up Borg and Borgmatic
MIT License
221 stars 98 forks source link

Error on borgmartic configuration on a Debian 10 and 11 server #88

Open calbasi opened 2 years ago

calbasi commented 2 years ago

I have this error on a Debian 10 / 11 server:

TASK [m3nu.ansible_role_borgbackup : Add Borgmatic Configuration] ** fatal: [fuster.calbasi.net]: FAILED! => {"changed": false, "msg": "AnsibleError: Unexpected templating type error occurred on (# Full config: https://torsion.org/borgmatic/docs/reference/config.yaml\nlocation:\n source_directories:\n{% for dir in borg_source_directories %}\n - {{ dir }}\n{% endfor %}\n\n # Stay in same file system (do not cross mount points).\n one_file_system: {{ borg_one_file_system }}\n repositories:\n{% if borg_repository is iterable and (borg_repository is not string and borg_repository is not mapping) %}\n {% for repo in borg_repository %}\n - {{ repo }}\n {% endfor %}\n{% elif borg_repository is defined and borg_repository is string %}\n - {{ borg_repository }}\n{% endif %}\n\n # Store atime into archive.\n atime: {{ borgmatic_store_atime }}\n\n # Store ctime into archive.\n ctime: {{ borgmatic_store_ctime }}\n\n{% if borg_exclude_patterns|length %}\n # Any paths matching these patterns are excluded from backups. Globs and tildes\n # are expanded. See the output of \"borg help patterns\" for more details.\n exclude_patterns:\n{% for dir in borg_exclude_patterns %}\n - '{{ dir }}'\n{% endfor %}\n{% endif %}\n\n{% if borg_exclude_from|length %}\n # Read exclude patterns from one or more separate named files, one pattern per\n # line. See the output of \"borg help patterns\" for more details.\n exclude_from:\n{% for dir in borg_exclude_from %}\n - {{ dir }}\n{% endfor %}\n{% endif %}\n\n # Exclude directories that contain a CACHEDIR.TAG file. See\n # http://www.brynosaurus.com/cachedir/spec.html for details.\n exclude_caches: true\n\n # Exclude directories that contain a file with the given filename.\n exclude_if_present: .nobackup\n\n # Alternate Borg remote executable. Defaults to \"borg\".\n # remote_path: borg1\n{% if borg_remote_path %}\n remote_path: {{ borg_remote_path }}\n{% endif %}\n\n# Repository storage options. See\n# https://borgbackup.readthedocs.io/en/stable/usage.html#borg-create and\n# https://borgbackup.readthedocs.io/en/stable/usage/general.html#environment-variables for\n# details.\nstorage:\n encryption_passphrase: {{ borg_encryption_passphrase }}\n\n # The standard output of this command is used to unlock the encryption key. Only\n # use on repositories that were initialized with passcommand/repokey encryption.\n # Note that if both encryption_passcommand and encryption_passphrase are set,\n # then encryption_passphrase takes precedence.\n # encryption_passcommand: secret-tool lookup borg-repository repo-name\n{% if borg_encryption_passcommand %}\n encryption_passcommand: {{ borg_encryption_passcommand }}\n{% endif %}\n\n # Type of compression to use when creating archives. See\n # https://borgbackup.readthedocs.org/en/stable/usage.html#borg-create for details.\n # Defaults to no compression.\n compression: auto,zstd\n\n # Remote network upload rate limit in kiBytes/second.\n{% if borg_remote_rate_limit %}\n remote_rate_limit: {{ borg_remote_rate_limit }}\n{% endif %}\n\n # Command to use instead of just \"ssh\". This can be used to specify ssh options.\n # ssh_command: ssh -i ~/.ssh/id_ed25519\n{% if borg_ssh_command %}\n ssh_command: {{ borg_ssh_command }}\n{% endif %}\n\n # Umask to be used for borg create.\n umask: 0077\n\n # Maximum seconds to wait for acquiring a repository/cache lock.\n lock_wait: {{ borg_lock_wait_time }}\n\n # Name of the archive. Borg placeholders can be used. See the output of\n # \"borg help placeholders\" for details. Default is\n # \"{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}\". If you specify this option, you must\n # also specify a prefix in the retention section to avoid accidental pruning of\n # archives with a different archive name format. And you should also specify a\n # prefix in the consistency section as well.\n archive_name_format: '{hostname}-{now:%Y-%m-%d-%H%M%S}'\n\n # Bypass Borg error about a repository that has been moved.\n relocated_repo_access_is_ok: {{ borgmatic_relocated_repo_access_is_ok }}\n\n# Retention policy for how many backups to keep in each category. See\n# https://borgbackup.readthedocs.org/en/stable/usage.html#borg-prune for details.\n# At least one of the \"keep\" options is required for pruning to work.\nretention:\n{% if borg_retention_policy.keep_secondly is defined %}\n # Number of secondly archives to keep.\n keep_secondly: {{ borg_retention_policy.keep_secondly }}\n{% endif %}\n\n{% if borg_retention_policy.keep_minutely is defined %}\n # Number of minutely archives to keep.\n keep_minutely: {{ borg_retention_policy.keep_minutely }}\n{% endif %}\n\n{% if borg_retention_policy.keep_hourly is defined %}\n # Number of hourly archives to keep.\n keep_hourly: {{ borg_retention_policy.keep_hourly }}\n{% endif %}\n\n{% if borg_retention_policy.keep_daily is defined %}\n # Number of daily archives to keep.\n keep_daily: {{ borg_retention_policy.keep_daily }}\n{% endif %}\n\n{% if borg_retention_policy.keep_weekly is defined %}\n # Number of weekly archives to keep.\n keep_weekly: {{ borg_retention_policy.keep_weekly }}\n{% endif %}\n\n{% if borg_retention_policy.keep_monthly is defined %}\n # Number of monthly archives to keep.\n keep_monthly: {{ borg_retention_policy.keep_monthly }}\n{% endif %}\n\n{% if borg_retention_policy.keep_yearly is defined %}\n # Number of yearly archives to keep.\n keep_yearly: {{ borg_retention_policy.keep_yearly }}\n{% endif %}\n\n # When pruning, only consider archive names starting with this prefix.\n # Borg placeholders can be used. See the output of \"borg help placeholders\" for\n # details. Default is \"{hostname}-\".\n prefix: '{hostname}-'\n\n# Consistency checks to run after backups. See\n# https://borgbackup.readthedocs.org/en/stable/usage.html#borg-check and\n# https://borgbackup.readthedocs.org/en/stable/usage.html#borg-extract for details.\nconsistency:\n # List of one or more consistency checks to run: \"repository\",\n # \"archives\", \"data\", and/or \"extract\". Defaults to\n # \"repository\" and \"archives\". Set to \"disabled\" to disable\n # all consistency checks. \"repository\" checks the consistency\n # of the repository, \"archives\" checks all of the archives,\n # \"data\" verifies the integrity of the data within the\n # archives, and \"extract\" does an extraction dry-run of the\n # most recent archive. Note that \"data\" implies \"archives\".\n checks:\n {% for checks in borgmatic_checks %}\n - {{ checks }}\n {% endfor %}\n\n # Restrict the number of checked archives to the last n. Applies only to the \"archives\" check.\n check_last: {{ borgmatic_check_last }}\n\n # When performing the \"archives\" check, only consider archive names starting with\n # this prefix. Borg placeholders can be used. See the output of\n # \"borg help placeholders\" for details. Default is \"{hostname}-\".\n prefix: '{hostname}-'\n\n# Shell commands or scripts to execute before and after a backup or if an error has occurred.\n# IMPORTANT: All provided commands and scripts are executed with user permissions of borgmatic.\n# Do not forget to set secure permissions on this file as well as on any script listed (chmod 0700) to\n# prevent potential shell injection or privilege escalation.\nhooks:\n # List of one or more shell commands or scripts to execute before creating a backup.\n before_backup:\n{% for cmd in borgmatic_before_backup_command %}\n - {{ cmd }}\n{% endfor %}\n\n # List of one or more shell commands or scripts to execute after creating a backup.\n after_backup:\n{% for cmd in borgmatic_after_backup_command %}\n - {{ cmd }}\n{% endfor %}\n\n # List of one or more shell commands or scripts to execute in case an exception has occurred.\n on_error:\n{% for cmd in borgmatic_failure_command %}\n - {{ cmd }}\n{% endfor %}\n\n{% for hook in borgmatic_hooks %}\n {{ hook }}: {{ borgmatic_hooks[hook] }}\n{% endfor %}\n): object of type 'NoneType' has no len()"}

PLAY RECAP ***** MYSERVER : ok=9 changed=5 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0

m3nu commented 2 years ago

Unexpected templating type error occurred object of type 'NoneType' has no len()

Could be an issue with your input. Doesn't look Debian-specific. We also test against Debian 10 and such an error would show up.

calbasi commented 2 years ago

My input? What input?

m3nu commented 2 years ago

The arguments you are passing to the role.