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.
 
 

59 lines
2.5 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={{ matrix_systemd_unit_home_path }}"
  15. ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-backup-borg 2>/dev/null || true'
  16. ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-backup-borg 2>/dev/null || true'
  17. ExecStartPre=-{{ matrix_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 --init --encryption {{ matrix_backup_borg_encryption }}"
  34. ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-backup-borg \
  35. --log-driver=none \
  36. --cap-drop=ALL \
  37. --read-only \
  38. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  39. --network={{ matrix_docker_network }} \
  40. --tmpfs=/tmp:rw,noexec,nosuid,size=100m \
  41. --mount type=bind,src={{ matrix_backup_borg_config_path }}/passwd,dst=/etc/passwd,ro \
  42. --mount type=bind,src={{ matrix_backup_borg_config_path }},dst=/etc/borgmatic.d,ro \
  43. {% for source in matrix_backup_borg_location_source_directories %}
  44. --mount type=bind,src={{ source }},dst={{ source }},ro \
  45. {% endfor %}
  46. {% for arg in matrix_backup_borg_container_extra_arguments %}
  47. {{ arg }} \
  48. {% endfor %}
  49. {{ matrix_backup_borg_docker_image }}
  50. ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-backup-borg 2>/dev/null || true'
  51. ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-backup-borg 2>/dev/null || true'
  52. SyslogIdentifier=matrix-backup-borg
  53. [Install]
  54. WantedBy=multi-user.target