0

For the last two years Snapper has been working flawlessly to perform hourly snapshots (on the hour). A few days ago I noticed two snapshots are being taken every hour. One on the hour (HH:00), and the other at 1 minute after the hour (HH:01)

The snapper log file shows the same process ID for libsnapper for both of theses duplicate snapshots. Each hour there is a new process ID, but the duplicate snapshots are performed by the same process ID according to the logs. In the logs things look normal. The job is simply repeated twice, from what I can see.

snapper list-configs does not have any duplicate configs.

I had always had a systemd timer enabled and started for snapper-timeline.timer (which was set up in accord with Arch's wiki page for Snapper).

I have no root cron:

# crontab -l
no crontab for root

As far as I know, there is no cron for any user: /var/spool/cron/ is empty.

Here's the really strange thing. After stopping and disabling snapper-timeline.timer, the snapshots on the hour stop, but the snapshots 1 minute after the hour continue. This is true even after a reboot.

After the step above, there are no snapper-timeline.timer entries listed by systemctl:

$ systemctl --user list-timers
0 timers listed.
$ sudo systemctl list-timers
NEXT                         LEFT          LAST                         PASSED        UNIT                         ACTIVATES
Wed 2018-02-21 00:00:00 EST  1h 40min left Tue 2018-02-20 00:00:00 EST  22h ago       logrotate.timer              logrotate.service
Wed 2018-02-21 00:00:00 EST  1h 40min left Tue 2018-02-20 00:00:00 EST  22h ago       man-db.timer                 man-db.service
Wed 2018-02-21 00:00:00 EST  1h 40min left Tue 2018-02-20 00:00:00 EST  22h ago       shadow.timer                 shadow.service
Wed 2018-02-21 03:54:50 EST  5h 35min left Tue 2018-02-20 03:54:49 EST  18h ago       snapper-cleanup.timer        snapper-cleanup.service
Wed 2018-02-21 03:59:50 EST  5h 40min left Tue 2018-02-20 03:59:49 EST  18h ago       systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Mon 2018-02-26 00:00:00 EST  5 days left   Mon 2018-02-19 00:00:23 EST  1 day 22h ago fstrim.timer                 fstrim.service

Update:

As we know from the Arch Wiki Snapper page, under "Automatic timeline snapshots":

If you have a cron daemon, this feature [automatic hourly snapshots] should start automatically.

As I said above, I checked crontab -l as root and as my user and both were empty.

However, in my case I do have cronie installed (cronie is a cron daemon). Looking in /etc/cron.daily/ showed a snapper file and /etc/cron.hourly/ also contains a snapper file.

The remaining questions are:

  1. which user's crontab would show the Snapper cronjob?

  2. is there a way to make Snapper's cronjob inactive that will persist across package updates (while keeping the systemd timer active)? I assume that if I simply delete the entries in /etc/cron.daily and /etc/cron.hourly/` they will get replaced when the Snapper package is updated. [UPDATE 2: I did a test that confirms this assumption. See comments.]

  • systemctl list-timers && systemctl --user list-timers. – jasonwryan Feb 21 '18 at 2:57
  • @jasonwryan - neither list-timers command shows any snapper-timeline timers active. Yet the hourly snapshots continue. – MountainX Feb 21 '18 at 3:22
  • What is in the snapper-cleanup.service? If it isn't there, when the process starts, find the PID and see what is starting it. – jasonwryan Feb 21 '18 at 3:31
  • Also, please include the output of systemctl list-unit-files --state=enabled. – jasonwryan Feb 21 '18 at 3:35
  • @jasonwryan I updated the question. Your comment helped because it showed me that cronie was active on this system even though crontab -l showed no entries. – MountainX Feb 21 '18 at 4:46
1

Credit for this answer goes to @jasonwryan.

As we know from the Arch Wiki Snapper page, under "Automatic timeline snapshots":

If you have a cron daemon, this feature [automatic hourly snapshots] should start automatically.

I checked crontab -l as root and as my user and both were empty.

However, in my case I do have cronie installed (cronie is a cron daemon). Package installation places a Snapper timeline cleanup script in /etc/cron.daily/ and the hourly snapshot script in/etc/cron.hourly/. (It does this even if Snapper systemd units have been enabled.)

If you prefer to use systemd timers, but keep a cron daemon for some odd jobs, Snapper is going to favor the cron daemon.

Assuming one needs to keep the cron daemon installed (as I do), but wishes to manager Snapper timers with systemd, the solution (thanks to @jasonwryan) is as follows:

  1. Edit /etc/pacman.conf`

  2. uncomment the NoExtract directive (if commented).

  3. add the following two files from the Snapper package to the NoExtract directive

    etc/cron.daily/snapper etc/cron.hourly/snapper

The syntax for adding multiple files is discussed here:

pacman.conf NoExtract syntax for filelist over multiple lines / Pacman & Package Upgrade Issues / Arch Linux Forums

Example resulting line in /etc/pacman.conf:

NoExtract = etc/cron.daily/snapper etc/cron.hourly/snapper

The solution works for me with cronie, but if you use a different cron daemon, your paths may differ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.