Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd timer service to trim backups #43

Open
kaipee opened this issue Jan 3, 2020 · 1 comment
Open

Systemd timer service to trim backups #43

kaipee opened this issue Jan 3, 2020 · 1 comment
Labels

Comments

@kaipee
Copy link

kaipee commented Jan 3, 2020

Probably not the best way to achieve this but I have created a systemd timer and service to automatically trim all NextBackup files, keeping a fixed amount (24 per day, 7 days = 168).

nextbackup-trim.timer

[Unit]
Description=Run NEXTBACKUP-TRIM hourly and on boot

[Timer]
OnBootSec=15min
OnUnitActiveSec=1hr

[Install]
WantedBy=timers.target

nextbackup-trim.service

[Unit]
Description=Trim the number of NextBackup backups

[Service]
Type=oneshot
ExecStart=/bin/bash -c "find /mnt/ncdata/ownbackup/ -maxdepth 1 -mindepth 1 -type d | tail -n +168 | xargs -n 1 rm -rf"

Create both files under /etc/systemd/system/ (ubuntu).
Start and enable the timer

sudo systemctl start nextbackup-trim.timer
sudo systemctl enable nextbackup-trim.timer
@pbek pbek added the question label Jan 3, 2020
@pbek
Copy link
Owner

pbek commented Jan 3, 2020

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants