Systemd file to restart Insync automatically [workaround]

Insync sometimes crashes and does not autostart again.

This systemd service file should take care of it.

[Unit]
Description=Insync Google Drive and Dropbox synchronizer
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/insync start
ExecStop=/usr/bin/insync quit
Restart=on-failure
RestartSec=10

[Install]
WantedBy=plasma-workspace.target

Put it into ~/.config/systemd/user/insync.service

and run

systemctl --user daemon-reload
systemctl --user enable insync.service
systemctl --user start insync.service

And it will autostart on startup. You might want to remove what insync puts in /etc/xdg/autostart or whatever it uses to autostart. I wish Insync adapted it itself, systemd is meant for this.

1 Like

Thank you for sharing this in great detail, @drew. I will send this to our engineers and see if they have any input/feedback/further questions.

I had to do something similar as insync crashes every time I use the media keys.

My .service looks like this though:

[Unit]
Description=Insync Keep Alive
After=network-online.target graphical-session.target
Wants=network-online.target graphical-session.target

[Service]
Type=forking
ExecStart=/usr/bin/insync start
ExecStop=/usr/bin/insync quit
Restart=on-failure
RestartSec=30

[Install]
WantedBy=graphical-session.target

The two main differences are:

  • WantedBy=graphical-session.target will work for the main DEs rather than just KDE.
  • I would have thought RemainAfterExit=yes would have caused problems so this is missing from mine.

Yes, that is indeed better. I previously had oneshot where RemainAfterExit might have made sense, but I changed it to forking because it would not restart on failure, I just forgot to remove that line. I am changing it in the original post for people who do not read the comments, thanks for the suggestion!

Actually, now that I tried it, systemctl restart and systemctl start does not work without RemainAfterExit=yes. From what I can find, Insync is not forking itself properly, so systemd files to track it well. Systemd would like a PID file, but that is also not provided, as far as I can tell. But it seemed to me the restarting after a crash worked, I will keep an eye on it.

After I posted this I did start having one or two issues with this so ended up changing it as below. This has ran for 2+ weeks without any problems now.

[Unit]
Description=Insync Keep Alive
After=network-online.target graphical-session-pre.target
Wants=network-online.target graphical-session-pre.target
PartOf=graphical-session.target

[Service]
Type=simple
ExecStart=/usr/bin/insync start --no-daemon
ExecStop=/usr/bin/insync quit
Restart=on-failure
RestartSec=10

[Install]
WantedBy=graphical-session.target
1 Like

yes, I also noticed that when I kill it myself, it restarts, but when it crashes on it own, it does not, I will try this too, thanks!

I’m late to this thread, but wanted to thank you both for posting this. The default autostart service crashes on startup and after hibernation for me on openSUSE Slowroll, but it runs perfectly otherwise. I replaced autostart with this systemd unit and it’s working nicely to keep it running.
Specifically using the systemd unit @Klz posted here.

Yes, I have been using Kiz’s file for more t han a month not and Insync is always on.