Slim command line client CLI-Sync

Use case:
Deploy Folder from Nextcloud to a Server. Example: “Download files” managed in Nextcloud, automatically synced to the Webserver.

Client should be minimal, without GUI and its dependencies.

Option 1:
Can the GUI of the desktop client be separated from the synchronisation tool?

Option 2:
For download only:
Simple API that lists all files with timestamp and checksum.
A simple client can then check the filesystem and download updated files and delete removed files.

Search Tags: CLI, daemon, headless, rsync, API

8 Likes

i’d love to have this feature as well!

2 Likes

Currently, installing owncloud-client-cmd on ubuntu xenial server pulls 152 packages and uses 287MB. With the --no-install-recommends option, it’s still 63 Packages and 189MB.

# apt install owncloud-client-cmd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme at-spi2-core colord colord-data dbus-x11 dconf-gsettings-backend dconf-service fontconfig gcr glib-networking glib-networking-common glib-networking-services gnome-keyring gsettings-desktop-schemas
  hicolor-icon-theme humanity-icon-theme libassuan0 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libboost-filesystem1.58.0 libboost-system1.58.0
  libcairo-gobject2 libcairo2 libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa libepoxy0 libevdev2 libexif12 libgbm1 libgck-1-0
  libgcr-3-common libgcr-base-3-1 libgcr-ui-3-1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0 libgtk-3-bin
  libgtk-3-common libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libinput10 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3 libmtdev1
  libowncloudsync0 libp11-kit-gnome-keyring libpam-gnome-keyring libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcre16-3 libpixman-1-0 libprotobuf-lite9v5 libproxy1v5 libqt5core5a libqt5dbus5 libqt5gui5
  libqt5keychain0 libqt5network5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5widgets5 librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsecret-1-0 libsecret-common libsm6 libsoup-gnome2.4-1 libsoup2.4-1
  libthai-data libthai0 libtxc-dxtn-s2tc0 libwacom-bin libwacom-common libwacom2 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa libwayland-server0 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4
  libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xkb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3
  libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 owncloud-client-l10n p11-kit p11-kit-modules pinentry-gnome3 qttranslations5-l10n ubuntu-mono x11-common
Suggested packages:
  colord-sensor-argyll cups-common gphoto2 gvfs liblcms2-utils libqt5libqgtk2 qt5-image-formats-plugins qtwayland5 librsvg2-bin avahi-daemon hplip libsane-extras sane-utils pinentry-doc
The following NEW packages will be installed:
  adwaita-icon-theme at-spi2-core colord colord-data dbus-x11 dconf-gsettings-backend dconf-service fontconfig gcr glib-networking glib-networking-common glib-networking-services gnome-keyring gsettings-desktop-schemas
  hicolor-icon-theme humanity-icon-theme libassuan0 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libboost-filesystem1.58.0 libboost-system1.58.0
  libcairo-gobject2 libcairo2 libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa libepoxy0 libevdev2 libexif12 libgbm1 libgck-1-0
  libgcr-3-common libgcr-base-3-1 libgcr-ui-3-1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0 libgtk-3-bin
  libgtk-3-common libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libinput10 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3 libmtdev1
  libowncloudsync0 libp11-kit-gnome-keyring libpam-gnome-keyring libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcre16-3 libpixman-1-0 libprotobuf-lite9v5 libproxy1v5 libqt5core5a libqt5dbus5 libqt5gui5
  libqt5keychain0 libqt5network5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5widgets5 librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsecret-1-0 libsecret-common libsm6 libsoup-gnome2.4-1 libsoup2.4-1
  libthai-data libthai0 libtxc-dxtn-s2tc0 libwacom-bin libwacom-common libwacom2 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa libwayland-server0 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4
  libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xkb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3
  libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 owncloud-client-cmd owncloud-client-l10n p11-kit p11-kit-modules pinentry-gnome3 qttranslations5-l10n ubuntu-mono
  x11-common
0 upgraded, 152 newly installed, 0 to remove and 0 not upgraded.
Need to get 42.4 MB of archives.
After this operation, 287 MB of additional disk space will be used.
Do you want to continue? [Y/n]

with --no-install-recommends:

# apt install owncloud-client-cmd --no-install-recommends
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fontconfig libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa libevdev2 libgbm1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgudev-1.0-0 libharfbuzz0b libice6 libinput10 libllvm3.8
  libmtdev1 libowncloudsync0 libpciaccess0 libpcre16-3 libproxy1v5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5keychain0 libqt5network5 libqt5sql5 libqt5sql5-sqlite libqt5widgets5 libsm6 libwacom-common libwacom2 libwayland-client0
  libwayland-server0 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1
  libxcb-util1 libxcb-xfixes0 libxcb-xkb1 libxdamage1 libxfixes3 libxi6 libxkbcommon-x11-0 libxkbcommon0 libxrender1 libxshmfence1 libxxf86vm1 owncloud-client-l10n x11-common
Suggested packages:
  libthai0 libqt5libqgtk2 qt5-image-formats-plugins qtwayland5
Recommended packages:
  libtxc-dxtn-s2tc0 | libtxc-dxtn0 qttranslations5-l10n libqt5svg5 gnome-keyring | kwalletmanager libwacom-bin
The following NEW packages will be installed:
  fontconfig libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa libevdev2 libgbm1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgraphite2-3 libgudev-1.0-0 libharfbuzz0b libice6 libinput10 libllvm3.8
  libmtdev1 libowncloudsync0 libpciaccess0 libpcre16-3 libproxy1v5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5keychain0 libqt5network5 libqt5sql5 libqt5sql5-sqlite libqt5widgets5 libsm6 libwacom-common libwacom2 libwayland-client0
  libwayland-server0 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1
  libxcb-util1 libxcb-xfixes0 libxcb-xkb1 libxdamage1 libxfixes3 libxi6 libxkbcommon-x11-0 libxkbcommon0 libxrender1 libxshmfence1 libxxf86vm1 owncloud-client-cmd owncloud-client-l10n x11-common
0 upgraded, 63 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.5 MB of archives.
After this operation, 189 MB of additional disk space will be used.
Do you want to continue? [Y/n]

My workaround with rsync and restricted ssh authorized key:

Links:

on nextcloud server add authorized key in /root/.ssh/authorized_keys
command="/usr/local/bin/rrsync -ro /var/www/nextcloud-data/<user>/files/<folder>",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAAB3Nz....kv rrsync_download

sync files read-only:
rsync -av --delete --progress -e 'ssh -i /root/.ssh/id_download -o IdentitiesOnly=yes' root@nextcloud-server:/source-subfolder /path/to/target

Hi. This post is a little old, but I thought someone may wish to know how I solved this necessity as well.

I have a client who uses nextcloud to backup / allow external access to their samba shares, essentially. At first I just had them run instances of the nextcloud sync client, but that was a bad solution all the way around.

I eventually settled on using csync2 which was triggered to sync by a samba logoff script as well as periodically via cron. The advantages to csync2 is that it is much more intelligent than rsync and can detect things like file deletion so the sync is not just one way.

If you want to use rsync though I highly recommend you patch it with the “–detect-renamed” patch so that it doesn’t transfer the file over the network everytime someone renames a file.

1 Like

i wrote a blog: NextcloudCMD without GUI
Probably this could help?
Cheers, Carsten

1 Like

Hi Carsten.
Interesting solution to sync regularry using cron.
But do I get that right, you still need to download the complete client package?

Hi Marcus,
that is correct.
But no gui is required on your server, so you may run and sync your server using cli only!
Cheers, Carsten

It doesn’t sync files shared by others.

That link is 404ed.

A huge thanks for this discussion! As a newbie I was very interesting to read.

Hi there…
Any new ideas for this issue?