webMethods API Portal tutorial
It is always a recommended good practice to backup your data periodically, so that you can recover your environment even incase of a data loss or a system failure. As part of this tutorial we will explore ways of automating the regular backup with webMehtods API Portal.
Backup script
#!/bin/sh
SAGInstallDir="/opt/Portal104"
backupDir="/FS/backups"
today=b"$(date +%d)_$(date +%m)"
echo "creating backup directory $backupDir/$today"
mkdir -p $backupDir/$today
cd $SAGInstallDir/API_Portal/server/acc
cmd="backup tenant default to \"$backupDir/$today\""
echo "executing command $cmd"
./acc.sh -h localhost -u Clous -pwd g3h31m -p 18010 "$cmd"
echo "sucessfully completed the backup"
Above one is a simple shell script to make use of ACC command line utiltiy to trigger a backup. We use the ACC command backup tenant to trigger the backup process. We supply the newly created backup directory as a arguement to the backup tenant command, so that the created backup will be placed in the directory given.
Note: Please remember to configure SAGInstallDir/backupDir based on your installation.
ACC+ localhost>help backup tenant
Performs a backup of all data of the specified tenant to the specified location.
Using the parameters "username" and "password", a user name and password will be specified for a user in the relevant tenant who has sufficient administrative privileges for all applications.
If the target path specified refers to an existing directory, the backup file name will be generated automatically and the file be saved to this directory. If the target path points to an existing file, the user is asked to confirm overwriting of this file. If the target file directory does not exist, it will be created. Optionally, it is possible to specify what applications are to be included in the backup operation.
Syntax:
"backup" tenant" <tenantId> ("for" "applications"? <appType> ("," <appType> )*)? ("to" <path>)? (<key> "=" <value> ("," <value>)*)*
Examples:
backup tenant softwareag
Performs a backup of the softwareag tenant using the default user name and password (system/manager). The resulting backup file will be stored in the current ACC working directory.
backup tenant softwareag username="alice" password="70ps3cr37"
Performs a backup of the softwareag tenant using the specifed user name and password. The resulting backup file will be stored in the current ACC working directory.
backup tenant softwareag to c:\temp
Performs a backup of the softwareag tenant using the default user name and password (system/manager). The resulting backup file will be stored in the specified directory.
backup tenant softwareag for UMC, ABS
Performs a backup of the softwareag tenant using the default user name and password (system/manager) and including only the applications UMC and ABS. The resulting backup file will be stored in the current ACC working directory.
Type help <nonTerminal> to get help for a non-terminal used within the command.
|
Scheduling the script
We can make use of crontab to schedule the backup script that we created to execute periodically.
crontab
-e
add the entry -> 51 07 * * * <FileLocation>/<filename>.sh
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
Below cron expression schedules the backup.sh to be exeucted daily at 12:00
crontab
-l
0 12 * * * /home/myuser/backup.sh
The backup file used in this tutorial can be found here.
#backup#wiki#webMethods#API-Portal