Feature request: "Do not backup when on battery"

Hello uroni,
urbackup is great. But there’s something that I think it’s missing: having many notebooks/windows tablets or 2in1, I’d love to back up them with urbackup. The problem is: it would be great to have an option (also for Macs and Linux) to enable/disable backups when on battery, to avoid battery drain.

Do you think it could be possible?

Thank you

From what I can see there is no API that allows you to ‘pause’ a backup (although it is in the GUI, it isn’t exposed in CLI) but you could perhaps use a pre-backup script that ‘checks’ your charge status and exits with a non-zero code if it’s not on AC power. That would prevent your backup from ‘starting’ but not interrupt a running backup. If there were ever a PAUSE command in the CLI, you could have it trigger on a state change. Not sure if that’s something that’s easy to build into the C code.

On OS X you could use “pmset -g batt” and parse the first line.
On Windows “WMIC Path Win32_Battery”
On Linux use upower or a value from the /sys/class/power_supply tree (depending on kernel version, hardware and software installed, YMMV)

Thank you very much, I’ll look into it (and script). The best solution would be an option on the configuration, managed internally by urbackup