Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

66 rivejä
3.1 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. [Unit]
  3. Description=Matrix Borg Backup
  4. {% for service in matrix_backup_borg_systemd_required_services_list %}
  5. Requires={{ service }}
  6. After={{ service }}
  7. {% endfor %}
  8. {% for service in matrix_backup_borg_systemd_wanted_services_list %}
  9. Wants={{ service }}
  10. {% endfor %}
  11. DefaultDependencies=no
  12. [Service]
  13. Type=oneshot
  14. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  15. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill matrix-backup-borg 2>/dev/null || true'
  16. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-backup-borg 2>/dev/null || true'
  17. ExecStartPre=-{{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-backup-borg \
  18. --log-driver=none \
  19. --cap-drop=ALL \
  20. --read-only \
  21. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  22. --network={{ matrix_docker_network }} \
  23. --tmpfs=/tmp:rw,noexec,nosuid,size=100m \
  24. --mount type=bind,src={{ matrix_backup_borg_config_path }}/passwd,dst=/etc/passwd,ro \
  25. --mount type=bind,src={{ matrix_backup_borg_config_path }},dst=/etc/borgmatic.d,ro \
  26. {% for source in matrix_backup_borg_location_source_directories %}
  27. --mount type=bind,src={{ source }},dst={{ source }},ro \
  28. {% endfor %}
  29. {% for arg in matrix_backup_borg_container_extra_arguments %}
  30. {{ arg }} \
  31. {% endfor %}
  32. {{ matrix_backup_borg_docker_image }} \
  33. sh -c "borgmatic rcreate --encryption {{ matrix_backup_borg_encryption }}"
  34. # The `CAP_DAC_OVERRIDE` capability is required, so that `root` in the container
  35. # can read the `/etc/borgmatic.d/config.yaml` (`{{ matrix_backup_borg_config_path }}/config.yaml`) file,
  36. # owned by `matrix:matrix` on the filesystem.
  37. #
  38. # `/root` is mountes as temporary filesystem, because we're using `--read-only` and because
  39. # Borgmatic tries to write to at least a few paths under `/root` (`.config`, `.ssh`, `.borgmatic`).
  40. ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-backup-borg \
  41. --log-driver=none \
  42. --cap-drop=ALL \
  43. --cap-add=CAP_DAC_OVERRIDE \
  44. --read-only \
  45. --network={{ matrix_docker_network }} \
  46. --tmpfs=/root:rw,noexec,nosuid,size=100m \
  47. --tmpfs=/tmp:rw,noexec,nosuid,size=100m \
  48. --mount type=bind,src={{ matrix_backup_borg_config_path }}/passwd,dst=/etc/passwd,ro \
  49. --mount type=bind,src={{ matrix_backup_borg_config_path }},dst=/etc/borgmatic.d,ro \
  50. {% for source in matrix_backup_borg_location_source_directories %}
  51. --mount type=bind,src={{ source }},dst={{ source }},ro \
  52. {% endfor %}
  53. {% for arg in matrix_backup_borg_container_extra_arguments %}
  54. {{ arg }} \
  55. {% endfor %}
  56. {{ matrix_backup_borg_docker_image }}
  57. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill matrix-backup-borg 2>/dev/null || true'
  58. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-backup-borg 2>/dev/null || true'
  59. SyslogIdentifier=matrix-backup-borg
  60. [Install]
  61. WantedBy=multi-user.target