My laptop is configured to go to sleep after two minutes of being idle.
But it also suspends while a backup to an external disk is running :(
The solution is to tell your system that something important is running and that it should not go to sleep/suspend or to shut down.
With systemd you can use the command „systemd-inhibit“. Read the man page… (man systemd-inhibit).