If testing locally isn't an option, then the most straight forward approach would be to use disk volume snapshots/backups to your advantage. These will still cost $$$, but will save you time in the long run. You should then separate your bash script into different working segments/scripts that can be tested individually. Once your server is provisioned, run a script, then take a snapshot. If it was successful, run the next script, take a snapshot, then rinse and repeat. If your script fails, modify the script, revert to the last successful snapshot, then try again.
NOTE: I'm not sure if you can take snapshots of virtual machine disks in IBM Cloud/Softlayer, but it looks like you can create a VM image pretty easily.
Backing up virtual machine images
You can back up a virtual machine
image in your instance. This function creates a copy of the virtual
machine image and cloud configuration that can be restored later.
Additionally, you can manage these backup images. Details about the
backup image are as follows:
The backup image is an exact copy of the
virtual machine image and the cloud configuration. No image cleanup is
The backup image cannot be deployed as a new instance. It
can be used only to restore the associated virtual machine image and
Only the project owner (or an administrator) has
access to restore the backup virtual machine images and backup virtual
If you are using an OpenStack cloud, only one instance backup
operation is allowed at the same time. If another user is running a
backup and you start one on the same instance, you receive an error
that states there is a conflicting request. To perform a backup, you
must wait until the other backup is finished.
OpenStack PowerVM® and
z/VM® instances do not support this action.
If the instance is deleted
by using IBM® Cloud Manager with OpenStack, the associated backups are