nextcloud

NextcloudCMD without GUI

We will install and configure the Nextcloudcmd withou any GUI to sync all your data to a Nextcloud Server silently. Therefore we will add the Nextcloud repository as root to our Ubuntu Server, install the Nextcloud client, create a shell script and configure a cronjob to sync your data automatically:

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: Do 17. Aug 08:02:03 CEST 2017
————————————-
nextcloudcmd version 2.3.2
————————————-
/NextcloudCMD by C-RIEGER.DE…
————————————-
END: Do 17. Aug 08:02:07 CEST 2017
————————————-

From now, all your data will be synced hourly.


Have fun and enjoy your Nextcloud!

Carsten Rieger