Output of rest-server --version
rest-server version rest-server 0.14.0-dev compiled with go1.24.4 on linux/amd64
What should rest-server do differently? Which functionality do you think we should add?
Optionally exit after a user-configurable idle period (i.e. no open client connections).
What are you trying to do? What problem would this solve?
Allow a backup server running the restic rest server to automatically sleep to conserve energy when not in use.
When backups are not needed, my backup server is in a low power sleep state (currently ACPI S3 "suspend to RAM", but S4 "hibernate" or S5 "standby/off" are also possible). Overall, this saves approx 90% of the energy which would otherwise be consumed by the backup server if it was left running continuously.
The proposed enhancement allows this to be done more reliably, with greater energy savings, and with less manual monitoring and intervention.
Current arrangement
The system wakes by RTC alarm shortly before a "rendezvous time" that coincides with the backup clients' scheduled backup time.
Arranging wake-up for a "normally-asleep" server is straightforward e.g. by:
- A Linux systemd timer which uses a cron-like
OnCalendar trigger with WakeSystem=true
- Similar wake-on-RTC functionality on non-systemd servers.
- "Wake on LAN" (also allows easy remote wake for restores)
(I use a combination of wake-on-RTC for scheduled backups and wake on LAN for manual restores).
Deficiencies
It's not currently trivial to put the server back to sleep once scheduled backups have completed. I currently use a manually configured timer to sleep the system at a fixed time-of-day, but this is prone to both:
- Sleeping too soon: unexpected large changesets can mean that the backups "overrun" and fail to complete with knock-on implications such as stale locks as well as reduced security.
- Staying awake unnecessarily: The safety margin necessary to cover nearly all backups results in +30% unnecessary power usage in my case.
Proposed Solution
Do not run the rest-server when there are no active backups in progress. Do not sleep the system when rest-server is running.
I'm already using systemd socket activation to automatically start the rest server on client connect.
If the server exits once it becomes idle (i.e. no active connections) then systemd-inhibit can be used to postpone a suspend whilst the rest server remains running.
Other mechanisms (e.g. a script with a lock file) could be used to inhibit sleep on non-systemd systems.
Additional benefits
- Servers with extremely limited RAM could benefit by minimising memory usage when the rest server is not in use.
- Potential to limit rest-server RAM usage growth over weeks/months (due to memory fragmentation).
- Mechanisms like
systemd-inhibit (which this feature enables) can also be used to postpone scheduled jobs such as automatic security updates (e.g. reboot due to new kernel or upgraded system firmware) so that they don't interrupt in-progress backups.
- Allows the continued use of cheap older hardware which might otherwise have prohibitively high financial and environmental running costs (if running continuously or otherwise for longer periods).
- The continued use (on a "light duty" basis) of older hardware avoids energy and resource expenditure ("embodied energy") due to manufacturing new replacement hardware.
Did rest-server help you today? Did it make you happy in any way?
Thanks for writing and maintaining restic, I find it very useful!
Output of
rest-server --versionrest-server version rest-server 0.14.0-dev compiled with go1.24.4 on linux/amd64What should rest-server do differently? Which functionality do you think we should add?
Optionally exit after a user-configurable idle period (i.e. no open client connections).
What are you trying to do? What problem would this solve?
Allow a backup server running the restic rest server to automatically sleep to conserve energy when not in use.
When backups are not needed, my backup server is in a low power sleep state (currently ACPI S3 "suspend to RAM", but S4 "hibernate" or S5 "standby/off" are also possible). Overall, this saves approx 90% of the energy which would otherwise be consumed by the backup server if it was left running continuously.
The proposed enhancement allows this to be done more reliably, with greater energy savings, and with less manual monitoring and intervention.
Current arrangement
The system wakes by RTC alarm shortly before a "rendezvous time" that coincides with the backup clients' scheduled backup time.
Arranging wake-up for a "normally-asleep" server is straightforward e.g. by:
OnCalendartrigger withWakeSystem=true(I use a combination of wake-on-RTC for scheduled backups and wake on LAN for manual restores).
Deficiencies
It's not currently trivial to put the server back to sleep once scheduled backups have completed. I currently use a manually configured timer to sleep the system at a fixed time-of-day, but this is prone to both:
Proposed Solution
Do not run the rest-server when there are no active backups in progress. Do not sleep the system when rest-server is running.
I'm already using systemd socket activation to automatically start the rest server on client connect.
If the server exits once it becomes idle (i.e. no active connections) then
systemd-inhibitcan be used to postpone a suspend whilst the rest server remains running.Other mechanisms (e.g. a script with a lock file) could be used to inhibit sleep on non-systemd systems.
Additional benefits
systemd-inhibit(which this feature enables) can also be used to postpone scheduled jobs such as automatic security updates (e.g. reboot due to new kernel or upgraded system firmware) so that they don't interrupt in-progress backups.Did rest-server help you today? Did it make you happy in any way?
Thanks for writing and maintaining restic, I find it very useful!