X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/blobdiff_plain/0ed8fae25157152e3b89343e0e77548216228fdd..001bec529747e994540cbace860016591a323e33:/NextcloudBackup.sh?ds=inline diff --git a/NextcloudBackup.sh b/NextcloudBackup.sh index a0299e6..4c735de 100644 --- a/NextcloudBackup.sh +++ b/NextcloudBackup.sh @@ -3,7 +3,7 @@ # # 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 @@ -24,6 +24,8 @@ backupMainDir=$1 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") @@ -265,7 +267,7 @@ if [ ${maxNrOfBackups} != 0 ] 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