Borg (Servicio de backup)
Software: Borg
Web oficial: https://www.borgbackup.org
Documentación oficial: https://borgbackup.readthedocs.io/en/stable/
Conversación inicial en el foro de anartist: https://forum.anartist.org/t/backups-incrementales-con-borg/793
Ubicaciones importantes:Lorem/ipsum
Comandos de gestión
Listado de comandos creados por @marcel: https://cloud.anartist.org/s/fKiXt4ytMtp3p4E
#!/bin/bash
sshfs anartist@XX.XXX.XXX.XX:/home/anartist/borgbackup /root/borgbackup/
export BORG_REPO=/root/borgbackup/cloud
export BORG_PASSPHRASE=''
info () { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
info "Entering Maintenance Mode"
sudo -u www-data php /usr/share/nginx/nextcloud/occ maintenance:mode --on
info "Starting DB backup"
dbdate=`date +"%Y%m%d-%H%M%S"`
mysqldump --opt --password=XXXXXXXXXX --user=root nextcloud | gzip > /backup/base/nextcloud-sqlbkp_${dbdate}.sql.gz
info "Starting Remote backup"
/usr/bin/borg create --verbose --stats ::backup_$(date +%Y%m%d) /usr/share/nginx/nextcloud-data /usr/share/nginx/nextcloud /backup/base/nextcloud-sqlbkp_${dbdate}.sql.gz /etc/nginx/conf.d/nextcloud.conf
backup_exit=$?
/usr/bin/borg prune --list --show-rc --keep-daily 7 --keep-weekly 4 --keep-monthly 6
prune_exit=$?
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
else
info "Backup and/or Prune finished with errors"
fi
fusermount -u /root/borgbackup/
info "Eliminating old db"
ls /backup/base/* -trd | head -n -2 | xargs --no-run-if-empty rm
info "Deactivating Maintenance Mode"
sudo -u www-data php /usr/share/nginx/nextcloud/occ maintenance:mode --off
info "Backup Finished"
exit ${global_exit}
No Comments