A laptop or mini PC that suspends in the middle of a long copy is annoying, and the fix does not need any change in the power settings.
systemd-inhibit runs a command and holds an inhibitor lock for as long as it runs. The lock is acquired before the command starts and released afterwards. Without options it blocks idle:sleep:shutdown:
systemd-inhibit --why="Copying photos" rsync -a /mnt/user/photos/ /mnt/backup/photos/
The --why text is the reason other programs show when they see the lock, and the default is “Unknown reason”. --who says who holds the lock and defaults to the command line. You can narrow what is blocked with --what, which takes a colon-separated list:
systemd-inhibit --what=sleep:idle --why="Long copy" rsync -a /mnt/user/photos/ /mnt/backup/photos/
To see what is holding things back on a machine, list every active lock with its reason:
systemd-inhibit --list
The default mode is block, which prohibits the requested operations without time limit. That includes a shutdown you ask for yourself, until the command ends. If you want a privileged user to be able to override it, look at --mode=block-weak, which is not enforced against operations started by privileged clients. The third mode, delay, only holds back sleep and shutdown for a limited time.
The lock only works on a system that runs systemd, and it does nothing against a hard power-off, a pulled plug or a crash.
Further reading: systemd-inhibit manual page