Skip to content

Instantly share code, notes, and snippets.

@Arano-kai
Last active January 22, 2024 20:36
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Arano-kai/cdacb092f8fe2b0eea2d927960fbb924 to your computer and use it in GitHub Desktop.
Save Arano-kai/cdacb092f8fe2b0eea2d927960fbb924 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