Skip to content

Instantly share code, notes, and snippets.

@mozlima
Forked from Arano-kai/duperemove-weekly@.timer
Created August 9, 2023 18:10
Show Gist options
  • Save mozlima/678235fed835cc9570ba03283c120bcc to your computer and use it in GitHub Desktop.
Save mozlima/678235fed835cc9570ba03283c120bcc to your computer and use it in GitHub Desktop.
SystemD service and timer templates for duperemove.
[Unit]
# Usage: systemctl enable --now duperemove-weekly@$(systemd-escape <path>).timer
# Utilize %J specifier for duration set.
# One can hardlink/copy with 'weekly' part changed
# to set other duration.
Description=Deduplicate %I at calendar event (%J)
After=local-fs.target
Requires=local-fs.target
Conflicts=shutdown.target rescue.target rescue.service emergency.service
[Timer]
Unit=duperemove@%i.service
RandomizedDelaySec=30
Persistent=true
OnCalendar=%J
[Install]
WantedBy=multi-user.target
[Unit]
Description=Recursive deduplication at %I
Documentation=man:duperemove(8)
Documentation=https://github.com/markfasheh/duperemove.git
Conflicts=shutdown.target rescue.target rescue.service emergency.service
After=local-fs.target
Before=shutdown.target
[Service]
Type=simple
Environment="HashDir=/var/lib/%p"
EnvironmentFile=-/etc/default/%p
MemoryHigh=1G
IOWeight=25
CPUWeight=25
ExecStartPre=/bin/mkdir -p ${HashDir}
ExecStartPre=-/bin/df -h %I
ExecStart=/usr/bin/duperemove --hashfile=${HashDir}/%i.hashfile -r -d -h $OPTIONS %I
ExecStopPost=-/bin/df -h %I
# Dir to store hash files. Each instance has own, named by $(systemd-escape <instance>).hashfile
#HashDir=/var/lib/duperemove
# Additional options for duperemove binary
#OPTIONS=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment