# Data Core/App Store Connect Update Manager (ipdc-update)

`ipdc-update` is a command-line tool that can be used to manually apply updates to standalone Data Core or App Store Connect instances, as well as performing administrative tasks such as enabling or disabling automatic updates, switching between release channels and restarting services.

Almost all commands must be run using elevated permissions and will return an error if run from a non-elevated command prompt.

> [!TIP]
> For the best experience, use the `ipdc-update install` command to add the installation directory to your `PATH` environment variable. See below for more details.


# Viewing Help

General help (including descriptions of all available commands) can be viewed by specifying the `--help` flag. For example:

```shell
ipdc-update --help
```

To view help for a specific command or subcommand, run the command or subcommand with the `--help` flag. For example:

```shell
ipdc-update channel list --help
```


# Adding to the `PATH` Environment Variable

We recommend adding the `ipdc-update` install location to the `PATH` environment variable for ease of use. Note that changes to the `PATH` only take effect in new terminal windows!


## User Installation

You can add the install location for `ipdc-update` to your personal `PATH` environment variable as follows:

```shell
ipdc-update install
```


## Machine-Wide Installation

To add the install location to the machine-wide `PATH` environment variable run the following from an **elevated command prompt**:

```shell
ipdc-update install --scope Machine
```



# Collecting Diagnostics

You can collect diagnostics for the Data Core or App Store Connect service and runtime by running the following command:

```shell
ipdc-update diagnostics collect
```

This will create a zip file in the current directory containing logs and configuration information for the service and runtime.

Additional options are available such as specifying the output directory and modifying the maximum log file age to include. For more information view the help for the command.


# Service Restarts

Commands that modify the configuration of the service or the Data Core/App Store Connect runtime require the service to be restarted before the changes take effect.

If you need to run multiple commands in a row that require a service restart (for example, changing the current release channel and then installing the latest package in that channel), you can avoid the need for multiple restarts by manually stopping the service, running the desired commands, and then manually starting the service again. For example:

```shell
ipdc-update service stop
ipdc-update channel set Canary
ipdc-update package install --latest
ipdc-update service start
```


# View Status

To view the current status of the Data Core or App Store Connect service and runtime, run the following command:

```shell
ipdc-update status
```


# Release Channels

Data Core/App Store Connect packages are downloaded from a release channel (a NuGet package feed). 


## Viewing Available Release Channels

You can view the available release channels by running the following command:

```shell
ipdc-update channel list
```

By default, the following release channels are available:

* Stable
* Beta
* Canary
* Local (i.e. the `Packages` directory in the Data Core service's installation directory)


## Setting the Release Channel

You can set the release channel by running the following command:

```shell
ipdc-update channel set <CHANNEL>
```


## Adding a Custom Release Channel

To add a custom release channel, create an `appsettings.json` file in `%LOCALAPPDATA%\Intelligent Plant\ipdc-update` and configure the channel as follows:

```json
{
    "Channels": {
        "MyChannel": {
            "Source": "<PATH_TO_NUGET_FEED>",
            "Description": "<DESCRIPTION>"
        }
    }
}
```

To allow prerelease packages to be installed from the channel, add a `Prerelease` property to the channel configuration:

```json
{
    "Channels": {
        "MyChannel": {
            "Source": "<PATH_TO_NUGET_FEED>",
            "Description": "<DESCRIPTION>",
            "Prerelease": true
        }
    }
}
```

> [!TIP]
> To add a machine-wide custom release channel, add the channel definition to the `appsettings.json` file in `%PROGRAMDATA%\Intelligent Plant\ipdc-update` instead.


# Automatic Updates

By default, the Data Core service automatically checks for and installs updates every 30 minutes. 


## Setting the Automatic Update Schedule

To view the current automatic update schedule, run the following command:

```shell
ipdc-update automatic-updates schedule get
```

To set the automatic update schedule, run the following command:

```shell
ipdc-update automatic-updates schedule set <CRON_EXPRESSION>
```

For example, to set the automatic update schedule to run on the first Tuesday of the month at 8:00 AM, run the following command:

```shell
ipdc-update automatic-updates schedule set "0 0 8 ? 1/1 TUE#1 *"
```

> [!TIP]
> We recommend using a CRON expression generator such as [CronMaker](http://www.cronmaker.com/) to create the desired schedule.


## Disabling/Enabling Automatic Updates

To disable automatic updates, run the following command:

```shell
ipdc-update automatic-updates disable
```

To enable automatic updates, run the following command:

```shell
ipdc-update automatic-updates enable
```


# Applying Updates


## Listing Available Packages

To view the latest package versions for the current release channel, run the following command:

```shell
ipdc-update package list
```

To view only package versions that are newer than the currently installed version, run the following command:

```shell
ipdc-update package list --newer-packages-only
```


## Installing Packages

To install the latest package version for the current release channel, run the following command:

```shell
ipdc-update package install --latest
```

To install a specific package version, run the following command:

```shell
ipdc-update package install <VERSION>
```


# Backups

Backups are automatically created by default before installing an update with the `package install` subcommand.


## Viewing Available Backups

To view the available backups, run the following command:

```shell
ipdc-update backup list
```


## Creating a Backup

To manually create a backup, run the following command:

```shell
ipdc-update backup create
```


## Restoring a Backup

To restore a specific backup, run the following command:

```shell
ipdc-update backup restore <BACKUP_FILE>
```

To choose from the list of available backups, run the following command:

```shell
ipdc-update backup restore
```
