Repository navigation
Conversation
…snapshot While a snapshot is created, checked for space, deleted or restored, the running instance now writes what it is doing to /var/run/lock/timeshift/status next to the lock: pid, mode, action, snapshot name, progress, seconds remaining and the counts. The file is readable by every user and is removed with the lock, so a panel applet or a second window can show the same progress the window shows today. A scheduled run's progress was only printed to a stdout nobody reads. The total for that progress was the file count saved when Timeshift was set up (Main.first_snapshot_count). On a system that has grown since, the bar passes 100 % long before the end (linuxmint#461). Copies now count against the snapshot they link from, and deletes against the snapshot being deleted, as restores already did; the saved figure is only used when there is no snapshot yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During a scheduled snapshot nothing outside the process knows how far it has got. The percentage
is printed to stdout, which cron throws away, and the window refuses to open while it runs.
With this change the running instance writes a small JSON file next to the lock,
/var/run/lock/timeshift/status, about once a second while it creates, deletes or restores asnapshot or checks the free space. It holds the pid, the lock mode, what it's doing, the snapshot
name,
progress,seconds_remainingand the counts, i.e. the same numbers the window shows. Anyonecan read it, it's written through a rename so a reader never gets half a file, and it goes away
with the lock. It lives outside the backup mount on purpose. When I followed a run by reading
rsync-loginside/run/timeshift/<pid>/backup, the open file kept the mount busy and Timeshiftfailed to unmount it at the end ("E: Failed to unmount").
The same commit also fixes the total those numbers are based on. Copies counted against
snapshot_countfrom timeshift.json, which is saved once during setup. Mine says 1,612,943 whilemy snapshots now have about 1,968,000 entries, so the bar would end near 122 % (#461 looks like
the same thing). Copies now count against the snapshot they link from, deletes against the
snapshot being deleted, like restores already do. The saved figure is still used when there's no
snapshot yet.
On a scratch disk image with 40,220 entries and
snapshot_countleft at 1000, the last progressline of a second snapshot was
4022.00% completeon master and100.00% completewith thisbranch. The status file during that run looked like this:
One thing I didn't solve here. An incomplete snapshot has no file_count, so deleting one still
falls back to the saved figure.
I also ran it for one real snapshot of my system (1.97 million entries, 12 minutes). The status
file was rewritten every second the whole time, and the bar moved like this:
It ends a little over 100 % (100.21 % on stdout), because the system had about 2,600 more
entries than the snapshot it linked from. That seems fine to me.
Two other pull requests build on this file: one for the window (opening it while a scheduled
snapshot runs) and one for the panel hint in mintreport.