saibotk
524bfe4fd4
This sets the timeout to 20h, because full backups usually take longer and also enabled progress logs, to see if the job is actually still doing something.
33 lines
1,016 B
Desktop File
33 lines
1,016 B
Desktop File
[Unit]
|
|
Description=Start lvm backup using duplicity.
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
|
|
TimeoutSec=20h
|
|
|
|
# Creating snapshots
|
|
{% for item in 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 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 /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 backup_vols %}
|
|
ExecStopPost=/usr/bin/umount /dev/{{ item.vg_name }}/{{ item.lv_name }}_snap
|
|
{% endfor %}
|
|
|
|
# Remove snapshots
|
|
{% for item in backup_vols %}
|
|
ExecStopPost=/usr/sbin/lvremove -f {{ item.vg_name }}/{{ item.lv_name }}_snap
|
|
{% endfor %}
|
|
|