Sync NextCloud Files on the Command Line
nextCloud and ownCloud having the same codebase, you can use the nextCloud command line client.
Fetch the owncloud repository key:
wget -nv https://download.owncloud.org/download/repositories/production/Debian_9.0/Release.key -O Release.key
Add the owncloud repository key:
apt-key add Release.key
Remove the key file:
rm Release.key
Add the ownCloud repository to your sources:
echo 'deb http://download.owncloud.org/download/repositories/production/Debian_9.0/ /' > /etc/apt/sources.list.d/owncloud.list
Add https as a possible transport for packages:
apt-get install apt-transport-https
Update your package data:
apt-get update
Now, install the command line client:
apt-get install owncloud-client-cmd
As of writing, there is a known issue with running in command line mode for the first time when required files don’t exist. See Debian bug report #900287.
The workaround is to manually create the files (be mindful to do this as root for /etc/ and your require user for ~/):
mkdir -p /etc/owncloud-client/
touch /etc/owncloud-client/sync-exclude.lst
mkdir -p ~/.local/share/data/ownCloud/
Now we can add a crontab entry to automatically sync at an interval, since the command line client does not detect changes automatically like the GUI client does:
crontab -e
This assumes you already have a nextCloud running somewhere and a local directory where you want to mirror the content.
*/15 * * * * owncloudcmd --user user --password pass /media/nextcloud-mirror/ "https://host.domain.tld/remote.php/webdav/" >>/home/user/.local/share/data/ownCloud/crontab-sync.log 2>&1