Two way sync nextcloud from command line

Hi :slight_smile:

How does one do a two way sync from command line? I don’t want to use the entire gui nextcloud desktop client.

I’ve looked at nextcloudcmd, but it seems to only “sync” from your device to the cloud, not the other way around. So if there is a new file on the cloud, it won’t pull it down.

nextcloudcmd is really cool, but would be a whole lot better if it was two-way.

I have no experience with this client but it looks 2-way sync is intended:

In this manner, nextcloudcmd processes the differences between client and server directories and propagates the files to bring both repositories to the same state. Contrary to the GUI-based client, nextcloudcmd does not repeat synchronizations on its own. It also does not monitor for file system changes.

In other words you need to start nextcloudcmd every time you want to sync (or use cron for automated sync) - maybe you missed this fact…

another option would be to use every sync software you like and connect with NC server using WebDAV…

You right. The documentation does imply it’s a two-way sync. Odd. I was seeing one-way sync from only laptop → server.

Let me investigate again and report back.

(It wasn’t the repeat sync part, I was aware of that and had it cron’ed thanks)

You can try, a NextCloud Client Command Line Interface for Rust.

Why not? Can you say more about what you are trying to do?

When you say “entire gui”, I’m thinking you are concerned with it using too many system resources. Is that right? The Nextcloud desktop client seems decent to me… it is fast and light enough that I don’t notice it. I haven’t caught it misbehaving in the background (e.g. using more memory, network, or CPU than I expect). More than that I find the desktop GUI indispensable for my use case (desktop sync). I often tweak what folders are sync’d, I use it for MFA, I resolve sync conflicts, and I can easily see if/when it is running and what it is doing (sitting idle, syncing, paused, conflicted).

What platform is the client? That may make a difference.

I’m on Ubuntu and it automatically shows my Nextcloud location in /run/user/$UID/gvfs/$DAVDETAILS… I can access that from the Files app (Nautilus) or the command line. I’ve used rsync to sync folder hierarchies to/from there. That might work on other platforms too.

I had another use case where I needed to copy data into my Nextcloud from a script. I hacked some Python webdav code to upload a file and retrieve the internal URL of that file. Would that be helpful to you?

Thanks, I didn’t know about this. Will check it out, if the official cli client option doesn’t work for me.

OK all. Update, I was being a bit stupid I think. I had some bad syntax in my command and I think it wasn’t syncing at all.

I figured out my syntax issue and it works nicely now.

I prefer a cli 2 way sync called from cron, rather then the nextcloud gui app. I’m using EXWM on guix distro, so don’t really have a system tray and prefer the sync to just be called via cron and sync specific dirs.

final command output example

nextcloudcmd -s -u user -p 'password' /home/ds/src/ds-org > /dev/null 2>&1