33 lines
1 KiB
Desktop File
33 lines
1 KiB
Desktop File
[Unit]
|
|
Description=Start lvm backup using duplicity.
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
|
|
TimeoutSec=20h
|
|
|
|
# Creating snapshots
|
|
{% for item in lvm_self_backup_vols %}
|
|
ExecStartPre=/usr/sbin/lvcreate -L 1G -n {{ item.lv_name }}_snap -s {{ item.vg_name }}/{{ item.lv_name }}
|
|
{% endfor %}
|
|
|
|
# Mounting snapshots
|
|
{% for item in lvm_self_backup_vols %}
|
|
ExecStartPre=/usr/bin/mount -o ro,nosuid,noexec{% if item.fstype is defined and item.fstype == "xfs" %},nouuid{% endif %} -t {{ item.fstype | default("ext4") }} /dev/{{ item.vg_name }}/{{ item.lv_name }}_snap /lvm_self_backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}
|
|
{% endfor %}
|
|
|
|
ExecStart=/usr/local/bin/backup-lvm
|
|
|
|
# Make sure duplicity container is gone
|
|
ExecStopPost=/usr/bin/docker rm --force duplicity-backup-lvm
|
|
|
|
# Unmount snapshots
|
|
{% for item in lvm_self_backup_vols %}
|
|
ExecStopPost=/usr/bin/umount /dev/{{ item.vg_name }}/{{ item.lv_name }}_snap
|
|
{% endfor %}
|
|
|
|
# Remove snapshots
|
|
{% for item in lvm_self_backup_vols %}
|
|
ExecStopPost=/usr/sbin/lvremove -f {{ item.vg_name }}/{{ item.lv_name }}_snap
|
|
{% endfor %}
|
|
|