Daily backup schedule using CLI

I would like to perform automatic backups using kopia snapshot create on a headless machine with the following schedule:

  • Run every day at 10AM;
  • If there is no internet connection (expected for this machine) then run the command next time there is connectivity.

The machine has systemd, but I cannot find an elegant solution that does this in a single unit file.

What solution do you propose/use?

What about using ExecStartPre= in your systemd service file to execute a command like ping? ExecStartPre= commands are required to exit successfully (unless prefixed with a “-”) for the regular command to start.