Spotfire® Server and Environment - Installation and Administration

Deleting library item versions using the command line

An administrator can delete old versions using the command line. This topic contains some scenarios and examples on how you can use the delete-library-versions command.

About this task

You can control versions for the entire library or for specific items found based on library search criteria. See also delete-library-versions.

Imagine you have a library, containing a single item, with the following versions:

(Version number) Name Comment Size Created
(5) 397 KB 2022-11-05T17:29:27,841+0100
(4) v2.0 404 KB 2022-09-07T15:23:07,505+0100
(3) 999 MB 2022-09-07T15:17:22,505+0100
(2) v1.1 277 KB 2022-08-05T14:16:28,958+0100
(1) v1.0 Original 108 KB 2015-12-16T13:58:59,060+0100

Scenarios

See Executing commands on the command line for more details on how to use the command line.

Run the command:

delete-library-versions --user=EXAMPLE\johndoe

In the example library above, this would keep versions 5 (because it is the current version), 4 (because it has a name), 2 (because it has a name), and 1 (because it has a name and a comment). It would delete version 3 (because it does not match any of the filters used by default, which includes keeping named versions and versions with comments).

Run the command:

 delete-library-versions --user=EXAMPLE\johndoe 
    --keep-commented-versions=false --keep-named-versions=false 
    --keep-smaller-than="1MB"

This would keep versions 1, 2, 4 and 5 (because these versions are all smaller than 1 MB), and delete version 3 (because it bigger than the specified size to keep).

Run the command:

delete-library-versions --user=EXAMPLE\johndoe 
    --keep-commented-versions=false --keep-named-versions=false 
    --keep-at-least=3

This would keep versions 3, 4, and 5 (because these are the three most recent versions), and delete the rest.

Run the command:

delete-library-versions --user=EXAMPLE\johndoe --keep-at-most=3

This would keep versions 5 (because it is the current version), 4 (because it has a name), and 2 (because it has a name), and delete version 3 (because it does not match any of the filters) and 1 (even though it matches two of the filters, version 1 will be dropped because there are already three more recent versions to keep).

Maintenance examples

To delete all except for the last 10 versions from all items in the Spotfire library, run this command:
config delete-library-versions --tool-password=password --user=user_library --search-query="*" --keep-at-least=10 --verbose=true --force
Tip: When you start out to define policies, you can run the delete-library-versions command without the --force parameter to get a preview of what is going to be deleted. If you do not include the -f or --force parameter you will be asked if you want to delete the versions listed.
Note: If you have a library with lots of versions (see next section), you should remember that running a command to delete many versions can take a long time and could potentially impact the performance of the Spotfire database.
To keep only library items created in the last month, run the following command:
config delete-library-versions --tool-password=password --user=user_library --search-query="*" --keep-created-after="a month ago" --keep-at-least=1 --verbose=true
If you are only interested in specifying versioning for Spotfire analysis files, then you can limit the search to just the dxp type:
config delete-library-versions --tool-password=password --user=user_library --search-query="type:dxp" --keep-at-least=10 --verbose=true
If you just want to delete versions for a specific item in the library, you can limit the search to a specific ID:
config delete-library-versions --tool-password=password --user=user_library --search-query="id:analysis-id-here" --keep-at-least=10 --verbose=true

Libraries with lots of existing versions

If version history has been enabled for a while without any regular maintenance, then the Spotfire library might contain some items that take up a lot of space because they have a lot of versions.

You can try to analyze your library to find out which analysis files are the most space consuming and selectively delete versions for an analysis using the id from the query results. For example, to delete all except the last 10 analyses for the version based on ID:
config delete-library-versions --tool-password=password --user=user_library --search-query="id:7fb69536-e8b9-4922-82d3-2c9bd18fae7b" --keep-at-least=10 --verbose=true
If an analysis has many versions, then it might make sense to run delete-library-versions in stages so you delete only a few versions at a time, for example, 10 at a time for an analysis that has 100 versions:
config delete-library-versions --tool-password=password --user=user_library --search-query="id:7fb69536-e8b9-4922-82d3-2c9bd18fae7b" --keep-at-least=90 --verbose=true

config delete-library-versions --tool-password=password --user=user_library --search-query="id:7fb69536-e8b9-4922-82d3-2c9bd18fae7b" --keep-at-least=80 --verbose=true

config delete-library-versions --tool-password=password --user=user_library --search-query="id:7fb69536-e8b9-4922-82d3-2c9bd18fae7b" --keep-at-least=70 --verbose=true

config delete-library-versions --tool-password=password --user=user_library --search-query="id:7fb69536-e8b9-4922-82d3-2c9bd18fae7b" --keep-at-least=60 --verbose=true

SQL Server as the Spotfire database

Use the MVCC/Row versioning mode when using SQL Server as the Spotfire database. See Setting up the Spotfire database (SQL Server) for more information.