Please note that this script requires write permissions on scripts folder in order to save dump to file and zip it. If your scripts do not have such permissions use the second version of script.
The only downside is that dump file won't be zipped.
Version with zipping. Requires write permissions on scripts folder.
Version without zipping. Write permissions are not required.