Improve Nextcloud backup script by removing redundant trap and recursing through symlinks for userdata

This commit is contained in:
Salt 2020-05-06 02:12:17 -05:00
parent 755249febf
commit 54d3aadb14

View File

@ -43,13 +43,14 @@ if cd "{{ nextcloud_webroot }}"; then
trap 'sudo -u www-data ./occ maintenance:mode --off' EXIT
date="$(date -Iseconds)"
log "Creating data backup"
tar czf "$OUTDIR/$date-data.tar.gz" "/var/nextcloud"
tar czhf "$OUTDIR/$date-data.tar.gz" "/var/nextcloud"
log "Creating webroot backup"
tar czf "$OUTDIR/$date-webroot.tar.gz" "{{ nextcloud_webroot }}"
log "Creating DB backup"
mysqldump nextcloud --single-transaction | gzip > "$OUTDIR/$date-db.sql.gz"
log "Unsetting maintenance mode"
sudo -u www-data ./occ maintenance:mode --off
trap : EXIT
else
log "Could not change directory: $OUTDIR"
return 3