diff --git a/templates/nextcloud-onlyoffice-config.yaml b/templates/nextcloud-onlyoffice-config.yaml
index f1c5a808026ff72d6d41eb9933809178af241949..6966f0b8b0681bb7427b0013a019ddaccff41a5f 100644
--- a/templates/nextcloud-onlyoffice-config.yaml
+++ b/templates/nextcloud-onlyoffice-config.yaml
@@ -26,6 +26,7 @@ data:
     #   * Persists and loads the config.json config file
     #   * Updates database indices, columns, keys, etc needed after NC upgrade
     #   * Writes a log to /var/www/html/data/postStart.log
+    set -e
     exec > /var/www/tmp/postStart-$(date +"%s").log
     exec 2> /var/www/tmp/postStart-$(date +"%s")_error.log
 
@@ -74,12 +75,6 @@ data:
 
     echo "Nextcloud is now installed, we can do our thing!"
 
-    # The `php occ status` command can, and is allowed to, fail when the `occ`
-    # file already exists, but the rest of the Nextcloud files have not been
-    # synchronized yet. However from this point in the script onwards,
-    # everything should succeed.
-    set -e
-
     # Enable app store so we can run `install` and `enable` commands
     run_as "php $occ config:system:set appstoreenabled --type boolean --value true"