NextcloudCMD without GUI

We will install and configure the Nextcloudclient (nextcloudcmd) 2.3.3 to sync all data headless and without any gui to your or federated Nextcloud Server silently. Therefore we will add the Nextcloud repository as root to your Ubuntu Server, install the Nextcloud client, create a shell script and configure a cronjob to sync your data automatically. Let’s start:

sudo -s
add-apt-repository ppa:nextcloud-devs/client

Then we run “apt update” and instal the Nextcloud Client:

apt update && apt install nextcloud-client

Create a shell script to sync your data:

vi /root/nccmd.sh

Paste the following rows:

#!/bin/bash
echo "-------------------------------------"
echo " START: $(date)"
echo "-------------------------------------"
nextcloudcmd -v
echo "-------------------------------------"
echo " NextcloudCMD by C-RIEGER.DE ..."
nextcloudcmd -u "YourUser" -p "Your-APP-Pass-Word" -s /your/local/path/ https://your.dedyn.io/remote.php/webdav/YourFolder/
echo "-------------------------------------"
echo " END: $(date)"
echo "-------------------------------------"
mail -s "NextcloudCMD" -a "From: Your Name <your@email.com>" Your@email.com< /home/ubuntuuser/bkup/nccmd.txt
exit 0

Substitute all the red ones properly. Save and quit the file (:wq!) and make the script executable:

chmod +x /root/nccmd.sh

Create a cronjob to sync your data @hourly:

crontab -e

Paste the following row:

@hourly /root/nccmd.sh > /home/ubuntuuser/bkup/nccmd.txt 2>&1

Verify, if the sync is working well by running:

/root/nccmd.sh > /home/ubuntuuser/bkup/nccmd.txt 2>&1

You should receive an email that looks like:

————————————-
START: So 07. Jan 08:02:03 CEST 2018
————————————-
nextcloudcmd version 2.3.3
————————————-
/NextcloudCMD by C-RIEGER.DE…
————————————-
END: So 07. Jan 08:02:07 CEST 2018
————————————-

From now, all your data will be synced hourly.


Carsten Rieger