Scanning Portal Backup Files For Malware
Scan backup files in a team portal for malware.
|
API
|
admin/api/backups/backupFolderName
|
|
URI
|
http://teamportal_url/admin/api/backups/backupFolderName where teamportal_url is the URL of a team portal.
|
|
HTTP Method
|
POST
|
|
Request Content-Type
|
application/xml
|
|
Request body example
|
<obj>
<att id="name">
<val>exportFolder</val>
</att>
<att id="param">
<obj class="exportFolderParams">
<att id="destFolder">
<val/>
</att>
<att id="passphrase"/>
<att id="endUserPassword">
<val>password</val>
</att>
<att id="paths">
<list>
<val>path_to_root_backup_folder</val>
</list>
</att>
<att id="snapshot"/>
<att id="type">
<val>normal</val>
</att>
<att id="useSingleQuery">
<val>true</val>
</att>
</obj>
</att>
</obj>
|
|
Expected Response status
|
200 OK
If a response such as 403 Forbidden is returned, check the password provided.
|
The request body:
destFolder – Mandatory: The value must be empty.
Note: The value must be empty and not null, therefore you must use <val/>.
endUserPassword – The password or passphrase to the backup folder. If the backup folder does not require a password, the value is empty or null. The password is not encrypted.
path – Mandatory: The value must not be empty. A list of the full paths to scan for viruses. The scan checks every file in the folder and in all the subfolders. For example, /webdav will scan all folders under the backup folder root. /webdav/test will scan the folder called test under the backup folder root.
snapshot – The ID of a snapshot. Leave empty.
type – Mandatory: The value must be normal.
useSingleQuery – Mandatory: The value must be true.
Note: The scan mode is a passive, log-only, scan mode, since backup sets are readonly.
cURL example
curl -X HEAD -i -v -b cookie-jar -H "Content-Type: application/xml" -d '<obj><att id="name"><val>exportFolder</val></att><att id="param"><obj class="exportFolderParams"><att id="destFolder"><val/></att><att id="endUserPassword"><val>'passphrase'</val></att><att id="paths"><list><val>'path'</val></list></att><att id="snapshot"/><att id="type"><val>normal</val></att><att id="useSingleQuery"><val>true</val></att></obj></att></obj>' -X POST "https://teamportal/admin/api/backups/folder_name
Where https://teamportal/admin/api/backups/folder_name is the URL to the top backup directory to scan. This directory and any subdirectories are scanned.
Example Antivirus Script
The following is an example of a script to run an antivirus scan:
#!/bin/bash
# USAGE: ./script.sh hostname user_name user_password path folder_name optional_passphrase
# example: ./script.sh teamportal.ctera.me admin mypassword mybackups /My Files/
clear
host=$1
user=$2
pass=$3
path=$4
folder_name=$5
passphrase=$6
#login
curl -X HEAD -i -c cookie-jar -H "Content-Type: text/xml" -X POST "https://"$host"/admin/api/login?j_username="$user"&j_password="$pass""
#Start Scan for Cloud Drive folder
resp=$(curl -X HEAD -i -v -b cookie-jar -H "Content-Type: application/xml" -d '<obj><att id="name"><val>exportFolder</val></att><att id="param"><obj class="exportFolderParams"><att id="destFolder"><val/></att><att id="endUserPassword"><val>'"$passphrase"'</val></att><att id="paths"><list><val>'"$path"'</val></list></att><att id="snapshot"/><att id="type"><val>normal</val></att><att id="useSingleQuery"><val>true</val></att></obj></att></obj>' -X POST "https://"$host"/admin/api/backups/"$folder_name"")
echo "$resp"
Note: The passphrase argument is used If a passphrase is required to access the backup folder.
The path to the backup of a gateway is similar to /webdav/backups and the folder name is the gateway user name.
Running the Script
Assume the script, as in the above example, is called av_scan_backup.sh, then the command to perform the scan on the backup folder, ctera-E74503, is similar to the following:
av_scan_backup.sh myportal.ctera.me admin password123 webdav ctera-E745
Or, if the ctera-E745 folder is password protected:
av_scan_backup.sh myportal.ctera.me admin password123 webdav ctera-E745 E745password
Note: If the folder is password protected and the password is not specified, the command fails with User password is missing.
To redirect the output to a log file and to run it in background:
av_scan_backup.sh myportal.ctera.me admin password123 webdav ctera-E745 >> /var/log/av_scan_backup.log &