# Restore

A database recovery command that restores data structures and data from a backup file to a specified database.

TIP

Database recovery commands support MySQL, SQLSERVER, PostgreSQL, and Oracle databases.

TIP

The database recovery command can be used not only to restore SiteServer CMS system data, but also to any occasion where data files need to be restored to the database.

# Usage

siteserver restore --directory <string>
    [--config-file <string>]
    [--includes <string>]
    [--excludes <string>]
    [--data-only]
    [--help]

Database Recovery Command must contain restore data from a specified folder --directory parameters.

# Options

Options Shorthand Description
--directory -d Recover data from the specified folder
--config-file -c Specify the configuration file Web.config path or file name
--includes Specify the table to be restored, multiple tables separated by commas, restore all tables by default
--excludes Specify the tables to be excluded, multiple tables separated by commas
--data-only Recover data only
--help -h Command description

TIP

By default, the recovery command will detect the database structure and set the database structure to the current version of the SiteServer CMS data structure. If this command is used for non-SiteServer CMS, set the --data-only parameter, the command will no longer detect and synchronize the SiteServer CMS database.

# Example

# Basic

By default, the restore command reads the Web.config file in the current directory, obtains the database connection string (ConnectionString), and restores the backup data in the specified backup folder to the database.

It is important to note that the SiteServer recovery command does not currently support incremental recovery. The backup data can only be restored to the specified database at one time. Therefore, it is recommended that the recovery command use the newly created empty database.

Before using the database recovery command, you need to ensure that the connection string (ConnectionString) in Web.config is a new database that needs to be restored.

The database recovery command needs to specify the backup storage folder to be restored by -d or --directory= by adding the folder name, such as:

siteserver restore -d mydir

This command will get the backup data from the mydir folder and restore it to the database. The recovery command will traverse the files in the backup folder one by one, and import the contents of the file completely into the recovery database. After the end, open the database and you will see the database. The database tables and data that need to be restored have been included, and the data recovery is successful.

# Specify the Web.config file

If the database information that needs to be restored is stored in another file, you can specify the config file by adding -c or --config-file= adding a file name.

The following figure shows two folders in the config file, backup.config and restore.config, which store the database connection string for which you want to back up data and the database connection string for which you want to restore data:

Open restore.config, you can see that there is a database type DatabaseType used to connect to the SiteServer CMS and the connection string ConnectionString.

Switch the command line to this folder and run:

siteserver restore -c backup.config -d 'backup/2019-01-20'

After the command is finished, the database is opened and you can see that the data recovery is successful.

Last Updated: 5/22/2020, 12:24:32 PM