Nextcloudcmd
| logo | |
| Maintainer | ReetP |
|---|---|
| Url | https://nextcloud.com |
| Source: | smeserver- |
| Licence | AGPLv3 |
| Category | |
| Tags | cloud, files, dropbox, seafile, pydio, ajaxplorer, owncloud, nextcloud |
Maintainer
Version
Description
Nextcloud is a suite of client-server software for creating and using file hosting services. It is functionally similar to Dropbox, although Nextcloud is free and open-source, allowing anyone to install and operate it on a private server.
nextcloudcmd is a command line tool that you can use to sync files from Nextcloud to another device.
Installation
There is a nextcloudcmd package available for Rocky 8 but it is old and it has no --path to select a specific folder from Nexcloud.
The older client can do a complete sync of all files, and then exclude files and folders:
--exclude [file] Exclude list file --unsyncedfolders [file] File containing the list of unsynced remote folders (selective sync)
It is easier to specify a particular folder that you want synced.
I did attempt to build a newer client from source but ended up in dependency hell.
I therefore decided to experiment with docker/podman
Authentication
It is better to have 2 factor authentication enabled and create a App Password.
This can be done in Settings/Security. At the bottom of the page you can create an App and App Password.
Building
Both docker and podman need their repsectoive compose packahes
Podman can beinstalled via podman-compose Docker compose can be accessed via the smeserver-docker package
Koozali users and group
We need to create a Koozali user and group. The group is for file permissions. Add users to this group abnd make sure it is used on ibays.
The user is the Koozali user that nextcloud client runs under.
mkdir -p /home/ncclient db accounts set ncclient group Description NCClient Gid 9001 Members admin Uid 9001 signal-event group-create ncclient usermod -s /bin/bash -d /home/ncclient ncclient
Now add required users to the ncclient group
Obtain the correct UID/GID from /etc/passwd and /etc/group for the next sections.
Docker
Install https://wiki.koozali.org/Docker
cd /home/e-smith/files/docker/configs/ git clone https://src.koozali.org/jcrisp/nextcloudfilesync.git cd nextcloudfilesync cp env.sample .env nano .env
Set the correct values. Use the UID and GID from above.
docker build --network host -t nextcloudwork . docker compose up -d occlient docker ps -a
Logging
docker logs -f occlient tail -f /opt/Nextcloud/log/latest.log
Enter the VM
docker exec -it occlient /bin/bash
We can stop and remove the image:
docker compose stop occlient docker system prune -a -f
Change your .env and rebuild as required.
Podman
Install https://wiki.koozali.org/Podman
Set the correct values. Use the UID and GID from above.
cd /home/e-smith/files/podman/configs git clone https://src.koozali.org/jcrisp/nextcloudfilesync.git cd nextcloudfilesync cp env.sample .env nano .env
podman build --network host -t nextcloudwork . podman compose up -d occlient podman ps -a
Logging
podman logs -f occlient tail -f /opt/Nextcloud/log/latest.log
More thoughts
How the image/container is built
The build reads the Dockerfile for build instructions.
That adds two scripts inside the container:
ENTRYPOINT ["/bin/bash","/opt/Nextcloud/docker-entrypoint.sh"] CMD ["/bin/bash", "/opt/Nextcloud/run.sh"]
The entrypoint is run whenever the container is started.
One consequence of this is that the run.sh script contains:
set -e
This forces the script to error and close if there are any errors with the nextcloudcmd - eg 503/404 errors etc.
At this point VM stops. If we have this in our compose file:
restart: alwaysrestart: always
The run script will error, and stop THE vm, the VM stops, and then restarts as per the compose file which can be seen in the logs.
If you have multiple directories to sync it will fail after the first one and the VM will then restart which again can be seen in the logs.
Other thoughts
The system that runs the nextcloudcmd is very primitive - just a bash script with a while loop.
It could probably benefit from using a systemd unit.
That could potentially enable syncing multiple folders/ibays more easily as the scritps are pretty agricultural.
Bugs
Probably lots.
Changelog
Only released version in smecontrib are listed here.