#
# Bash script for creating backups of Nextcloud.
#
-# Version 2.1.0
+# Version 2.1.1
#
# Usage:
# - With backup directory specified in the script: ./NextcloudBackup.sh
if [ -z "$backupMainDir" ]; then
# TODO: The directory where you store the Nextcloud backups (when not specified by args)
backupMainDir='/media/hdd/nextcloud_backup'
+else
+ backupMainDir=$(echo $backupMainDir | sed 's:/*$::')
fi
currentDate=$(date +"%Y%m%d_%H%M%S")
# Backup local external storage.
# Uncomment if you use local external storage
#echo "Creating backup of Nextcloud local external storage directory..."
+
#if [ "$useCompression" = true ] ; then
# tar -cpzf "${backupdir}/${fileNameBackupExternalDataDir}" -C "${nextcloudLocalExternalDataDir}" .
#else
then
nrOfBackups=$(ls -l ${backupMainDir} | grep -c ^d)
- if [[ ${nrOfBackups} > ${maxNrOfBackups} ]]
+ if [ ${nrOfBackups} -gt ${maxNrOfBackups} ]
then
echo "Removing old backups..."
ls -t ${backupMainDir} | tail -$(( nrOfBackups - maxNrOfBackups )) | while read -r dirToRemove; do