for Apache A+ SSL configuration check https://gist.github.com/GAS85/42a5469b32659a0aecc60fa2d4990308
Table of content:
- nextcloud-scripts-config.conf - Configuration file
- nextcloud-file-sync.sh - Do External Shares rescan only
- nextcloud-preview.sh - Automate preview generation
- nextcloud-rsync-to-remote.sh - Do data Folder rsync to remote via SSH with key Authentication, or into archive
- nextcloud-system-notification.sh - Get System Notifications into Nextcloud
- nextcloud-usage-report.sh - Generate report in cacti format
Central configuration file, very handy if you are using more then one script from this banch. Options are:
- Your NC OCC Command path e.g.
- Your NC log file path e.g.
- Your log file path for other output if needed e.g.
- Your PHP location if different from default e.g.
Basically it works out from the box. Only that you have to check you nextcloud path, log path and create a log file for
php occ output.
Will do external ONLY shares rescan for nextcloud.
Put it in
Run it under nextcloud user (for me it is www-data) basically twice per day at 2:30 and 14:30. You can run it also hourly. This is my cron config:
30 2,14 * * * perl -e 'sleep int(rand(1800))' && /usr/local/bin/nextcloud-file-sync.sh #Nextcloud file sync
Here I add perl -e 'sleep int(rand(1800))' to inject some random start time within 30 Minutes, but since it scans externals only it is not necessary any more. Your cron job config to run it hourly could be:
* */1 * * * /usr/local/bin/nextcloud-file-sync.sh
If you would like to perform WHOLE nextcloud re-scan, please add -all to command, e.g.:
Lets go through what it does (valid for commit 44d9d2f):
COMMAND=/var/www/nextcloud/occ <-- This is where your nextcloud OCC command located
OPTIONS="files:scan" <-- This is "Command" to run, just live it as it is
LOCKFILE=/tmp/nextcloud_file_scan <-- Lock file to not execute script twice, if already ongoing
LOGFILE=/var/www/nextcloud/data/nextcloud.log <-- Location of Nextcloud LOG file, will put some logs in Nextcloud format
CRONLOGFILE=/var/log/next-cron.log <-- location for bash log. In case when there is an output by command generated. AND IT IS GENERATED...
I have had some issues (like described here https://help.nextcloud.com/t/occ-files-cleanup-does-it-delete-the-db-table-entries-of-the-missing-files/20253) in older NC versions, so I added workaround from line 60 till 67 as
files:cleanup command, nut sure if it is needed now, but it does not harm anything.
Since last update, Application will detect if it is already run and will not be executed twice/parallel (https://help.nextcloud.com/t/clarity-on-the-crontab-settings-for-the-preview-generator-app/6144/54), so you can added it e.g. to execute each 20 Minutes as cron job directly. This means that nextcloud-preview.sh is not needed anymore, only make sense if you would like to have execution information directly in nextcloud logs.
This script will generate NC log output:
This script will do backup via RSYNC to remote machine via SSH Key authentication. You can edit key
--exclude=FolderToExclude to exclude folders such as:
data/appdata*/previewexclude Previews - they could be newly generated,
data/*/files_trashbin/exclude users trash-bins,
data/*/files_versions/exclude users files Versions,
data/updater*exclude updater backups and downloads,
*.ocTransferId*.partexclude partly uploaded data from backup.
Or you can even combine and do rsync into archive (with remote authentication via SSH Key) if you set
As per this tread I added simple script that will do check if updates or reboot is required and show it as NC notification. Works on Ubuntu 16.04+.
You only have to specify user from the Administrator group to get notifications via
This script works with https://apps.nextcloud.com/apps/user_usage_report
Will generate report and output it in cacti format. Supports Argument as "user" if you need to check statistic for one user only run ./nextcloud-usage_report.sh user to get specific user information. AS-IS without any warranty. Output fields are:
storage_all, storage_used, shares_new, files_all, files_new, files_read