diff options
-rw-r--r-- | bin/ncp/BACKUPS/nc-backup-auto.sh | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/bin/ncp/BACKUPS/nc-backup-auto.sh b/bin/ncp/BACKUPS/nc-backup-auto.sh index b668d8f6..c0008a9f 100644 --- a/bin/ncp/BACKUPS/nc-backup-auto.sh +++ b/bin/ncp/BACKUPS/nc-backup-auto.sh @@ -19,17 +19,28 @@ configure() cat > /usr/local/bin/ncp-backup-auto <<EOF #!/bin/bash source /usr/local/etc/library.sh -[ -x /usr/local/bin/ncp-backup-auto-before ] && /usr/local/bin/ncp-backup-auto-before +failed= +run_script() +{ + if [ -x /usr/local/bin/ncp-backup-auto-\$1 ] + then + /usr/local/bin/ncp-backup-auto-\$1 || failed="\$failed\${failed:+, } \$1" + fi +} + +run_script before /usr/local/bin/ncc maintenance:mode --on -/usr/local/bin/ncp-backup "$DESTDIR" "$INCLUDEDATA" "$COMPRESS" "$BACKUPLIMIT" || failed=true +/usr/local/bin/ncp-backup "$DESTDIR" "$INCLUDEDATA" "$COMPRESS" "$BACKUPLIMIT" || failed="\$failed\${failed:+, } main" /usr/local/bin/ncc maintenance:mode --off -[[ "\$failed" == "true" ]] && \ - notify_admin "Auto-backup failed" "Your automatic backup failed" -[ -x /usr/local/bin/ncp-backup-auto-after ] && /usr/local/bin/ncp-backup-auto-after +run_script after +if [[ -n "\$failed" ]] +then + notify_admin "Auto-backup failed" "The \$failed backup script(s) failed" +fi EOF chmod +x /usr/local/bin/ncp-backup-auto - echo "0 3 */${BACKUPDAYS} * * root /usr/local/bin/ncp-backup-auto" > /etc/cron.d/ncp-backup-auto + echo "0 3 */${BACKUPDAYS} * * root /usr/local/bin/ncp-backup-auto > /var/log/ncp.log 2>&1" > /etc/cron.d/ncp-backup-auto chmod 644 /etc/cron.d/ncp-backup-auto service cron restart @@ -54,4 +65,3 @@ install() { :; } # along with this script; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA - |