Skip to content

Latest commit

 

History

History
118 lines (96 loc) · 5.1 KB

snadmin-tools.md

File metadata and controls

118 lines (96 loc) · 5.1 KB

SnAdmin tools

SnAdmin is the command line tool in sensenet for executing upgrade or custom packages. It also helps you with common operations related to the Content Repository or web folder files of the sensenet web application. This article is about the latter: the SnAdmin tools.

In previous sensenet versions there were separate command line tools for these operations. From version 7.0 these are replaced by simple SnAdmin tools, so that you do not have to maintain multiple configuration files, only the one for the SnAdminRuntime executable.

In most cases SnAdmin packages contain many steps that may add new dlls, new content to the repository or even change the database schema. But we also offer simple built-in packages for common operations like importing or exporting content items so that you do not have to create packages manually, just execute them. This article is for operators and developers about these built-in packages (SnAdmin tools) that you can use out-of-the box, in a way that is similar to executing simple commands.

Warning: most of the following tools require the local sensenet web site to be stopped as they access the same index.

Tool packages

An SnAdmin tool is technically an SnAdmin package that resides in the web\Admin\tools folder. Usually these tool packages are very simple, containing only a few built-in steps. When you execute a tool, you actually execute one of these packages with providing a few parameters - e.g. what do you want to import or which part of the repository do you want to re-index. The command line parameters are the same parameters that these built-in steps have.

For example this is how you execute the import tool:

SnAdmin import source:"c:\localrepo\new-articles" target:"/Root/Sites/MySite/articles"

The tool above will import the usual Content structure from the provided source file system directory to the Content Repository folder provided as the target parameter.

Tool parameters

Most of these tools have parameters. You can get a list of available parameters by using the -HELP command line argument:

SnAdmin import -help

List of SnAdmin tools

To execute these tools you only have to open a command line from the web\Admin\bin folder and execute SnAdmin the same way as you execute any package.

SnAdmin [toolname] [parameters]

import

Imports Content items from the file system to the repository.

SnAdmin import source:"c:\localrepo\new-articles" target:"/Root/Sites/MySite/articles"

export

Exporting a folder:

SnAdmin export source:"/Root/Sites/MySite/articles" target:"c:\localrepo"

Exporting only selected (filtered) content items using the Content Query syntax:

SnAdmin export source:"/Root/Sites/MySite/articles" target:"c:\localrepo" filter:"+TypeIs:Article +CreationDate:<@@CurrentDate+3days@@"

delete

Deletes a content from the repository.

SnAdmin delete path:/Root/MyFolder/MyContent

seturl

Setting a url on the default site:

SnAdmin seturl url:demo.example.com

A more complex scenario:

SnAdmin seturl url:demo.example.com site:MySite authenticationType:Windows

index

Rebuild the index for a content subtree (for example a workspace or library) or the whole Content Repository (in case of a large repository this may take time).

Recreate the whole index from predefined index documents stored in the database. This will not reindex content items (soft reindex).

SnAdmin index

Repopulate the index of a subtree.

SnAdmin index path:"/Root/Sites/MySite/MyFolder"

Reindex content items in both the database and the index (hard reindex). This will load content items and re-generate index documents from scratch (instead of loading predefined index documents from the db).

SnAdmin index level:DatabaseAndIndex

createeventlog

Creates the default event log for sensenet so that you can see entries in the Windows Event Viewer tool.

SnAdmin createeventlog

Creates a named event log for your project.

SnAdmin createeventlog logname:"MyProject"

deleteeventlog

Deletes an event log along with its registered sources.

SnAdmin deleteeventlog logname:"MyProject"

cleanuppreviews

Removes preview images from the repository. The following parameters can be combined based on the actual environment and needs.

Deletes all preview images in a subtree:

SnAdmin cleanuppreviews path:"/Root/MySite"

Deletes preview images but preserves the first 5 for every document version.

SnAdmin cleanuppreviews maxIndex:5

Deletes all preview images for old document versions (the ones that are not the last major or minor version) and retains only the first 3 images for the latest versions.

SnAdmin cleanuppreviews mode:KeepLastVersions maxIndex:3

Deletes only unnecessary empty preview folders. In this mode no image is deleted.

SnAdmin cleanuppreviews mode:EmptyFoldersOnly