Nextcloud: Difference between revisions
imported>Onny mNo edit summary |
imported>Onny Add systemd-timer sync example |
||
Line 38: | Line 38: | ||
The argument <code>-h</code> will enable syncing hidden files. For demonstration purpose username and password are supplied as an argument. This is a security risk and shouldn't be used in production. | The argument <code>-h</code> will enable syncing hidden files. For demonstration purpose username and password are supplied as an argument. This is a security risk and shouldn't be used in production. | ||
Using [[Home-Manager]] we can create a systemd-timer which automatically runs the sync command every hour for the user <code>myuser</code>. | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
home-manager.users.myuser = { | |||
home.file.".netrc".text = ''default | |||
login example | |||
password test123 | |||
''; | |||
systemd.user = { | |||
services.nextcloud-autosync = { | |||
Unit = { | |||
Description = "Auto sync Nextcloud"; | |||
After = "network-online.target"; | |||
}; | |||
Service = { | |||
Type = "simple"; | |||
ExecStart= "${pkgs.nextcloud-client}/bin/nextcloudcmd -h -n --path /music /home/myuser/music https://nextcloud.example.org"; | |||
TimeoutStopSec = "180"; | |||
KillMode = "process"; | |||
KillSignal = "SIGINT"; | |||
}; | |||
Install.WantedBy = ["multi-user.target"]; | |||
}; | |||
timers.nextcloud-autosync = { | |||
Unit.Description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes"; | |||
Timer.OnUnitActiveSec = "60min"; | |||
Install.WantedBy = ["multi-user.target" "timers.target"]; | |||
}; | |||
startServices = true; | |||
}; | |||
}; | |||
</nowiki>}} | |||
The login credentials will be written to a file called <code>.netrc</code> used ''nextcloudcmd'' for authentication to the Nextcloud server. | |||
== Tips and tricks == | == Tips and tricks == |