Relaunch server on reboot

I am planning to run the repository server on a headless Debian machine.

On reboot, I need to manually reconnect to repository and then restart the server. Is there a way to automate this process, so that the server comes back up on reboots.

Thanks!

It is not really kopia issue but rather your OS - effectively you are asking how to start program (kopia server in this case) after reboot.

There are two most obvious options:

  1. old fashioned one - use crontab and @reboot schedule - Crontab Reboot: Execute a Job Automatically at Boot | phoenixNAP

  2. modern (and I would recommend this one) - use systemd - Use systemd to Start a Linux Service at Boot | Linode Docs

I included two links but you can find plenty of examples and guides on Internet.

If you make it working it would be nice if you share your solution.

1 Like

Iā€™m running an Ubuntu/Debian server. This works for me.

The EnvironmentFile=/backups/internal_bu_settings gives a single place where you can store your variable values ie; web_port=xxxx etc one variable per line


[Unit]
Description=SM Kopia Server - Internal
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/kopia server start --address=http://0.0.0.0:${web_port} --log-file=${log_file} --config-file=${config_file} -p $password --tls-cert-file=/etc/letsencrypt/live/${server_domain}/fullchain.pem --tls-key-file=/etc/letsencrypt/live/${server_domain}/privkey.pem --server-username=${web_gui_username} --server-password=${web_gui_password} --description='${backup_description}'
# this where the above variable settings come from
EnvironmentFile=/backups/internal_bu_settings
Restart=on-failure

[Install]
WantedBy=multi-user.target
1 Like