Skip to content

Prevent Mac sleep during backup #658

Closed

Description

@stefanbuehler

Mac falls asleep during backup, resulting in low level errors.

It would be great to have a recommended way to prevent this. Ideally a setting in Vorta.

I have also considered whether this could be achieved by putting caffeinate in the shell commands to run before backup, but from my understanding this would not work, since caffeinate never terminates, it just keeps the Mac from sleeping while it runs.

Of course sleep can be prevented altogether which fixes the problem but is not very environment friendly.

Activity

  1. samuel-w commented on Sep 18, 2020

    @samuel-w
    Contributor

    There is a caffeine python module: https://pypi.org/project/caffeine/
    And can use systemd-inhibit for Linux: https://github.com/systemd/python-systemd. Most Linux distros use systemd so we should be fine with just that.
    Just have to put it at the start of init and the end of finished_event in borg_thread

  2. added
    os:macosAffects only macOS
    good first issueSimple change to start learning code base
    priority:lowNice to have feature, minor improvement to functionality or usability
    on Sep 18, 2020
  3. stefanbuehler commented on Sep 19, 2020

    @stefanbuehler
    Author

    Yes, but would it be ok to simply make this the default behaviour (that sleep is not allowed while the borg command runs)? For me personally this would be perfectly fine. If no configuration is required, this appears to be relatively easy to implement.

  4. m3nu commented on Sep 19, 2020

    @m3nu
    Contributor

    This would need a OS-independent base class and then OS-specific implementations again.

    We also can't add the caffeine package as dependency, since it's too old and unmaintained. But reusing the code may be possible if the copyright can be clarified. https://github.com/jpn--/caffeine/blob/master/caffeine.py

  5. stefanbuehler commented on Sep 19, 2020

    @stefanbuehler
    Author

    I have in the meantime also explored if the problem can be solved by using pmset as pre-backup and post-backup shell commands to disable sleep and then reenable. However, the problem with that is that it would have to be run as root.

  6. samuel-w commented on Sep 19, 2020

    @samuel-w
    Contributor

    It's MIT licensed https://github.com/jpn--/caffeine/blob/master/LICENSE.txt, which is GPL3 compatable

  7. stefanbuehler commented on Oct 21, 2020

    @stefanbuehler
    Author

    My preliminary fix now is to run "caffeinate&" as pre-borg shell command, and "killall caffeinate" as post-borg shell command. A bit dirty, since it messes with other caffeinate commands in case there are any. But seems to work. The built-in solution discussed above would still be better, of course.

  8. self-assigned this
    on Oct 21, 2020
  9. unilynx commented on Jan 15, 2021

    @unilynx

    We also can't add the caffeine package as dependency, since it's too old and unmaintained. But reusing the code may be possible if the copyright can be clarified. https://github.com/jpn--/caffeine/blob/master/caffeine.py

    https://github.com/jpn--/caffeine/blob/master/LICENSE.txt shows a MIT license, and the name in the license file matches the author of the repository

    the code itself traces its origin back to another repository, which also indicates it should be considered MIT licensed - https://github.com/pudquick/pypmset

    so I think you would be in the clear to copy this code.

  10. removed their assignment
    on Jan 15, 2021
  11. locked and limited conversation to collaborators on Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueSimple change to start learning code baseos:macosAffects only macOSpriority:lowNice to have feature, minor improvement to functionality or usabilitytype:featureNew functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions