The below steps can be followed to setup automatic backups of the Cisco Meeting Server (CMS) using a Windows host. For similar steps for Linux, refer to the Acano Knowledge Base article here. The first steps involve creating a CMS user that can be used for SSH & SFTP, and generation of a private/public key pair. Once those steps are done, using PowerShell you can automatically back up your CMS by utilising the Windows Scheduler.
- Download putty.exe, puttygen.exe, psftp.exe, and plink.exe from here.
- Using putty SSH to the CMS and create a new user for performing automatic backups. For this example, backupuser is the username for this purpose.
- Open puttygen.exe, click Generate, you will need to move the mouse cursor around the Key area of the puttygen window.
- Once the generation completes click Save private key.
- In the Key area select all the text from ssh-rsa (inclusive) to '==' (inclusive). E.g.
- Using notepad paste this text onto a single line and save it as backupuser.pub, noting the filename matches the name of the user created earlier.
- Using an SFTP client such as WinSCP, copy the backupuser.pub file to the CMS.
- Using putty SSH to CMS, entering the host address in the format of @ as shown in the below. Before clicking Open, move to the next step.
- Expand the Putty navigation and click Connection > SSH > Auth. Click Browse and select the private key saved earlier (with extension .ppk).
- Click Open.
- Enter a password for the user as prompted.
At this point, it is now possible to SSH to the CMS using the steps above without requiring the user's password. The example PowerShell script below can now be used in concert with the Windows Task Scheduler to perform automatic backups of the CMS.
<# .SYNOPSIS This PowerShell script is used to backup CMS Servers. .DESCRIPTION This PowerShell script is used to backup CMS Servers. It depends on plink.exe and psftp.exe. It also needs appropriate CMS user configuration and public/private keys. .LINK . .NOTES . .PARAMETER Path The path to the . .PARAMETER LiteralPath Specifies a path to one or more locations. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. #> # Command line parameters [CmdletBinding()] Param( [Parameter(Mandatory=$True, HelpMessage="The CMS IP Address")] #The CMS IP Address [string]$ip_address, [Parameter(Mandatory=$True, HelpMessage="The CMS backup user name")] #The CMS backup user name [string]$user_name, [Parameter(Mandatory=$True, HelpMessage="The CMS backup users private key e.g. username.ppk")] #The CMS backup users private key e.g. username.ppk [string]$private_key, [Parameter(Mandatory=$True, HelpMessage="The plink.exe path")] #The plink.exe path [string]$PLINK, [Parameter(Mandatory=$True, HelpMessage="The psftp.exe path")] #The psftp.exe path [string]$PSFTP ) $timstamp = Get-Date -UFormat "%Y%m%d" $hostname = invoke-expression "$PLINK -ssh -i $private_key backupuser@$ip_address hostname" $backup_filename = $timstamp + "_" + $hostname $plink_command = "backup snapshot " + $backup_filename $conn_string = $user_name + "@" + $ip_address # Execute the PLINK backup snapshot command Invoke-Expression "$PLINK -ssh -i $private_key $conn_string $plink_command" # Construct the batch.txt in the working directory $psftp_command = "mget " + $backup_filename + ".bak *.crt *.key *.lic" $psftp_command | Out-File "batch.txt" -Encoding default sleep -Seconds 2 # Execute PSFTP batch command Invoke-Expression "$PSFTP -i $private_key -batch -b batch.txt $conn_string" 2> $null # Remove the batch.txt file rm "batch.txt"
PS C:\> .\CmsBackup.ps1 -ip_address 192.168.44.122 -user_name backupuser -private_key C:\backupuser.ppk -PLINK C:\plink.exe -PSFTP C:\psftp.exe