I'm running a RPi3 with
Operating System: Raspbian GNU/Linux 9 (stretch)
Kernel: Linux 4.14.79-v7+
Architecture: arm
In order to do a automatic backup I'd like to kill all "user services" to guarantee the integrity of the backup (e.g. Webserver, databases and so on)
I found that you can create a .target for isolation mode, but I'm having difficulties to set it up.
Of course my backup.target needs network access (to mount a network storage). I'd also like to have ssh enabled, so I'm not locked out of my system.
I created backup-net.target with the following
[Unit]
Description=Maintenance Mode with Networking and SSH
Requires=rescue.target network-online.target
Wants=sshd.service
After=rescue.target network-online.target
AllowIsolate=yes
But If i sudo systemctl isolate backup-net.target
, my RPi disconnects from the network and i can't connect via ssh until I manually reboot it.
For anyone wondering, i managed to get it by:
[Unit]
Description=Maintenance Mode with Networking and SSH $
Requires=rescue.target network-online.target dhcpcd.service
Wants=sshd.service wpa_supplicant.service
After=rescue.target network-online.target
AllowIsolate=yes
as /lib/systemd/system/backup-net.target