This commit is contained in:
Dennis Eichhorn 2024-03-22 22:31:11 +00:00
parent ec2a37fac9
commit c2c5f5b610
2 changed files with 24 additions and 10 deletions

View File

@ -6,7 +6,7 @@ MAIN_PATH="/var/www/html/jingga/"
# 0 4 * * * /var/www/html/jingga/Build/Backup/cron.sh # 0 4 * * * /var/www/html/jingga/Build/Backup/cron.sh
# Create backup # Create backup
${MAIN_PATH}Build/Backup/backup.sh > /tmp/backup.log ${MAIN_PATH}Build/Backup/local.sh > /tmp/backup.log
# Mail log files # Mail log files
${MAIN_PATH}Build/Backup/mail.sh ${MAIL_PASSWORD} /tmp/backup.log ${MAIN_PATH}Build/Backup/mail.sh ${MAIL_PASSWORD} /tmp/backup.log

View File

@ -22,17 +22,21 @@ sql_exit=$?
# Create file backup # Create file backup
BACKUP_PATH="/mnt/d/backup" BACKUP_PATH="/mnt/d/backup/backup.borg"
TO_BACKUP="/var/www/html" TO_BACKUP="/var/www/html"
REMOTE_USER="user" #REMOTE_USER="user"
REMOTE_SERVER="192.168.178.38" #REMOTE_SERVER="192.168.178.38"
REMOTE_PORT="2022" #REMOTE_PORT="2022"
# Setting this, so the repo does not need to be given on the commandline: # 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. # 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 ## Create repository
# borg init -v --encryption=repokey ${BACKUP_PATH} # borg init -v --encryption=repokey ${BACKUP_PATH}
@ -47,12 +51,14 @@ borg create \
--list \ --list \
--stats \ --stats \
--show-rc \ --show-rc \
--one-file-system \
--compression lz4 \ --compression lz4 \
--checkpoint-interval 86400 \
--exclude-caches \ --exclude-caches \
--exclude 'home/*/.cache/*' \ --exclude 'home/*/.cache/*' \
--exclude 'var/tmp/*' \ --exclude 'var/tmp/*' \
\ \
::'{hostname}-{utcnow}' \ ${BACKUP_PATH}::${TIMESTAMP}-$$-www \
${TO_BACKUP} ${TO_BACKUP}
backup_exit=$? backup_exit=$?
@ -78,17 +84,25 @@ borg compact ${BACKUP_PATH}
compact_exit=$? compact_exit=$?
## Check integrity
info "Checking repository"
borg check --verify-data ${BACKUP_PATH}
check_exit=$?
# Handle global exit code # Handle global exit code
global_exit=$(( sql_exit > backup_exit ? sql_exit : backup_exit )) global_exit=$(( sql_exit > backup_exit ? sql_exit : backup_exit ))
global_exit=$(( prune_exit > global_exit ? prune_exit : global_exit )) global_exit=$(( prune_exit > global_exit ? prune_exit : global_exit ))
global_exit=$(( compact_exit > global_exit ? compact_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 if [ ${global_exit} -eq 0 ]; then
info "Backup finished successfully" info "Backup finished successfully"
elif [ ${global_exit} -eq 1 ]; then 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 else
info "Backup, Prune, and/or Compact finished with errors" info "Backup, Prune, Compact and/or Check finished with errors"
fi fi
exit ${global_exit} exit ${global_exit}