X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/blobdiff_plain/4ab50409c84735f3897fe8371d6c91b938dfb6da..dd66e25d405afbc4e4cca6a997fb2776eadebf78:/NextcloudBackup.sh?ds=inline diff --git a/NextcloudBackup.sh b/NextcloudBackup.sh index 8c578d0..d1b1ed2 100644 --- a/NextcloudBackup.sh +++ b/NextcloudBackup.sh @@ -3,7 +3,7 @@ # # Bash script for creating backups of Nextcloud. # -# Version 1.0.0 +# Version 1.1.0 # # Usage: # - With backup directory specified in the script: ./NextcloudBackup.sh @@ -26,8 +26,6 @@ if [ -z "$backupMainDir" ]; then backupMainDir='/media/hdd/nextcloud_backup' fi -echo "Backup directory: $backupMainDir" - currentDate=$(date +"%Y%m%d_%H%M%S") # The actual directory of the current backup - this is a subdirectory of the main directory above with a timestamp @@ -65,12 +63,16 @@ dbPassword='mYpAsSw0rd' # TODO: The maximum number of backups to keep (when set to 0, all backups are kept) maxNrOfBackups=0 +# TODO: Ignore updater's backup directory in the data directory to safe space +# Set to true to ignore the backup directory +ignoreUpdaterBackups=false + # File names for backup files # If you prefer other file names, you'll also have to change the NextcloudRestore.sh script. fileNameBackupFileDir='nextcloud-filedir.tar.gz' fileNameBackupDataDir='nextcloud-datadir.tar.gz' -# TOOD: Uncomment if you use local external storage +# TODO: Uncomment if you use local external storage #fileNameBackupExternalDataDir='nextcloud-external-datadir.tar.gz' fileNameBackupDb='nextcloud-db.sql' @@ -102,6 +104,11 @@ function CtrlC() { exit 1 } +# +# Print information +# +echo "Backup directory: ${backupMainDir}" + # # Check for root # @@ -150,7 +157,14 @@ echo # Backup data directory # echo "Creating backup of Nextcloud data directory..." -tar -cpzf "${backupdir}/${fileNameBackupDataDir}" -C "${nextcloudDataDir}" . + +if [ "$ignoreUpdaterBackups" = true ] ; then + echo "Ignoring updater backup directory" + tar -cpzf "${backupdir}/${fileNameBackupDataDir}" --exclude="updater-*/backups/*" -C "${nextcloudDataDir}" . +else + tar -cpzf "${backupdir}/${fileNameBackupDataDir}" -C "${nextcloudDataDir}" . +fi + echo "Done" echo @@ -224,4 +238,4 @@ fi echo echo "DONE!" -echo "Backup created: ${backupdir}" \ No newline at end of file +echo "Backup created: ${backupdir}"