Deleting/purging galaxy data

We are running a local galaxy server and are trying to clear out old user data. We followed the instructions at: Cleaning up Dataset Objects - Galaxy Community Hub but nothing gets removed from disk. In addition, we get the following error running one of the scripts:

(.venv) [galaxy@galaxy1 cleanup_datasets]$ sh
Traceback (most recent call last):
File “/home/galaxy/galaxy/./scripts/cleanup_datasets/”, line 702, in
File “/home/galaxy/galaxy/./scripts/cleanup_datasets/”, line 212, in main
delete_datasets(app, cutoff_time, args.remove_from_disk, info_only=args.info_only, force_retry=args.force_retry)
File “/home/galaxy/galaxy/./scripts/cleanup_datasets/”, line 383, in delete_datasets
(, app.model.Dataset.table.c.state),
AttributeError: type object ‘Dataset’ has no attribute ‘table’
(.venv) [galaxy@galaxy1 cleanup_datasets]$

What is the proper procedure for removing old data from galaxy?