Skip to content

Commit

Permalink
nc-backup: make more robust to unexpected failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed May 14, 2018
1 parent 2ef575c commit 40a8431
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions etc/ncp-config.d/nc-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install()
{
cat > /usr/local/bin/ncp-backup <<'EOF'
#!/bin/bash
set -eE
DESTDIR="${1:-/media/USBdrive/ncp-backups}"
INCLUDEDATA="${2:-no}"
Expand All @@ -39,7 +40,13 @@ DATADIR=$( cd "$BASEDIR"/nextcloud; sudo -u www-data php occ config:system:get d
exit 1;
}
cleanup(){ local RET=$?; echo "Cleanup..."; rm -f "${DBBACKUP}" ; exit $RET; }
fail() { local RET=$?; echo "Abort..." ; rm -f "${DBBACKUP}" "${DESTFILE}"; exit $RET; }
trap cleanup EXIT
trap fail INT TERM HUP ERR
echo "check free space..."
mkdir -p "$DESTDIR"
SIZE=$( du -s "$DATADIR" | awk '{ print $1 }' )
FREE=$( df "$DESTDIR" | tail -1 | awk '{ print $4 }' )
Expand Down

0 comments on commit 40a8431

Please sign in to comment.