I created a script that backs up the selected folder to a remote server using rsync. Everything works fine when I manually run the script. But I would like it to be done automatically when the system shuts down. And this is where I get an error:
13:19:12 mx rsync_update.sh[9512]: Host key verification failed.
13:19:12 mx rsync_update.sh[9506]: rsync: connection unexpectedly closed (0 bytes received so far) [sender]
13:19:12 mx rsync_update.sh[9506]: rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]
The unit looks like this
[Unit]
Description=Clean on reboot,shutdown
Requires=network.targe rsync.service
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop=/usr/local/bin/rsync_backup.sh
[Install]
WantedBy=multi-user.target
Rsync works via ssh.
systemd
? – FelixJN Dec 11 '23 at 12:34Requires=network.targe
, it's missing the final 't'. – schrodingerscatcuriosity Dec 11 '23 at 13:15ssh
key to contact the server, but it's unable to find a (correct) key. I wonder if thessh-agent
has already shut down. If not, try explicitly choosing the identity file with-i /root/.ssh/id_rsa
(or equivalent). – Stewart Dec 11 '23 at 13:56root
can log in to the remote location. – FelixJN Dec 11 '23 at 16:23