diff --git a/Backup/cron.sh b/Backup/cron.sh index d28c64b..fe5bc46 100644 --- a/Backup/cron.sh +++ b/Backup/cron.sh @@ -6,7 +6,7 @@ MAIN_PATH="/var/www/html/jingga/" # 0 4 * * * /var/www/html/jingga/Build/Backup/cron.sh # Create backup -${MAIN_PATH}Build/Backup/backup.sh > /tmp/backup.log +${MAIN_PATH}Build/Backup/local.sh > /tmp/backup.log # Mail log files ${MAIN_PATH}Build/Backup/mail.sh ${MAIL_PASSWORD} /tmp/backup.log diff --git a/Backup/local.sh b/Backup/local.sh index 26088e7..fd08a9e 100644 --- a/Backup/local.sh +++ b/Backup/local.sh @@ -22,17 +22,21 @@ sql_exit=$? # Create file backup -BACKUP_PATH="/mnt/d/backup" +BACKUP_PATH="/mnt/d/backup/backup.borg" TO_BACKUP="/var/www/html" -REMOTE_USER="user" -REMOTE_SERVER="192.168.178.38" -REMOTE_PORT="2022" +#REMOTE_USER="user" +#REMOTE_SERVER="192.168.178.38" +#REMOTE_PORT="2022" # Setting this, so the repo does not need to be given on the commandline: -export BORG_REPO=ssh://${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_PORT}${BACKUP_PATH} +#export BORG_REPO=ssh://${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_PORT}${BACKUP_PATH} # See the section "Passphrase notes" for more infos. -export BORG_PASSPHRASE='sorden' +export BORG_PASSPHRASE='password' + +# Global settings +export BORG_RELOCATED_REPO_ACCESS_IS_OK=no +export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no ## Create repository # borg init -v --encryption=repokey ${BACKUP_PATH} @@ -47,12 +51,14 @@ borg create \ --list \ --stats \ --show-rc \ + --one-file-system \ --compression lz4 \ + --checkpoint-interval 86400 \ --exclude-caches \ --exclude 'home/*/.cache/*' \ --exclude 'var/tmp/*' \ \ - ::'{hostname}-{utcnow}' \ + ${BACKUP_PATH}::${TIMESTAMP}-$$-www \ ${TO_BACKUP} backup_exit=$? @@ -78,17 +84,25 @@ borg compact ${BACKUP_PATH} compact_exit=$? +## Check integrity +info "Checking repository" + +borg check --verify-data ${BACKUP_PATH} + +check_exit=$? + # Handle global exit code global_exit=$(( sql_exit > backup_exit ? sql_exit : backup_exit )) global_exit=$(( prune_exit > global_exit ? prune_exit : global_exit )) global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit )) +global_exit=$(( check_exit > global_exit ? check_exit : global_exit )) if [ ${global_exit} -eq 0 ]; then info "Backup finished successfully" elif [ ${global_exit} -eq 1 ]; then - info "Backup, Prune, and/or Compact finished with warnings" + info "Backup, Prune, Compact and/or Check finished with warnings" else - info "Backup, Prune, and/or Compact finished with errors" + info "Backup, Prune, Compact and/or Check finished with errors" fi exit ${global_exit}