Websites

The Website resource type represents a website backup within the CodeGuard application. A website belongs to a User.

Context

Requests to the Website resource can only be made by authenticated users. Requests must include a valid OAuth signature and key. See the OAuth section in the Appendix for more information.

Attributes

The following are the attributes associated with the Website resource. Whether they are required or optional is specified in the sections that follow.

id

Unique numeric ID used to identify the website resource in the CodeGuard application.

url

The URL parameter should contain the address of the website to be baked up. For example: www.myblog.com.

hostname

The server address that hosts the content of the website to be backed up. This can be a fully qualified domain name or IP address.

account

The username CodeGuard will use to authenticate with the host specified as hostname.

password

The password associated with the account provided. Note: You must provide either a key or a password, not both.

key

The key data to use for server authentication. Note: You must provide either a key or a password, not both. Keys are only supported for SFTP.

provider

This is the protocol to be used to connect to the host specified as hostname. Acceptable values for this field are ftp or sftp.

port

The port to be used to connect to the host specified as hostname.

monitor_frequency

An integer value representing the frequency that the website backup will be attempted.

owner_id

The numeric ID that represents which User in the CodeGuard application owns the website. Note: This parameter is for information purposes only and can not be modified via the API.

activated

A boolean indication of whether or not the initial backup has been completed. Note: This parameter is for information purposes only and can not be modified via the API.

notifications_enabled

A boolean value representing the preference for receiving email notifications related to this website backup.

container_size

The size in bytes of the website backup and any associated database backups stored in the CodeGuard system.

dir_path

The dir_path is the starting point for a backup and should correspond to the document root of the website. Only files and folders inside of this path will be backed up. The format of this parameter is a string. For example: '/home/username/www'.

disabled

Indicates whether or not the backup is enabled. Disabled resources will not be scheduled for backups.

schedule_at

The desired time of day for this backup to begin, in UTC.

Create Websites

This method is used to create new website backup records.

URI: /websites

Method: POST

Required Attributes

The request will not succeed without these attributes.

Optional Attributes
Example Request (Password-based Authentication)
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0&url=http://myblog.com&hostname=manuzak.com&account=jmanuzak&password=MyPassword&provider=ftp'
        
Example Request (Key-based Authentication)
curl -v -H "Content-type: application/json" -d "url=http://myblog.com&hostname=manuzak.com&account=jmanuzak&provider=sftp&key=-----BEGIN+RSA+PRIVATE+KEY-----%5CnMIIEogIBAAKCAQEAu7u7p6IZA1R%2BKUglQ1uRkKT3yVcu8eBwMVrOfcdzSm%2Bn04FJ%5CnlKRsLbiAINhMjkk0FeRU%2BMNqlx3%2BplyTOxALD8NmOalmk%2BTjA1iJGrwc%2FZ6s%2BT%2Bo%5CnYDIYGwg050PtKsl%2B74b6ceRSQDI2N3c96hXfxuejsyvf1W5jIzaEhrulZl5MyAyn%5CnNIGiePA6Z2ZD13lzzuVV7Ml7HnPRLf7IlBrp2nz6jZ9KddY12eVdKOOCba2v%2BUDp%5CnN1PMuhzeeV6Am6Qbg%2Bq3vSG6xqHmwEzKGyS589JxMP9%2FjYA0awd4FfnQX8wgLrYW%5CnmuTAvV8BeE%2BPqVA46x%2BaFnwgMOWJBLZMdV98awIDAQABAoIBAExqGfQd8vh8B%2B5d%5Cnw20rdJDf1UxLBHzH0mMEh1CDQtZlpHZfBchPNQlXNDAqWt7%2FxQe0LTIkuNpSBzlI%5CnLVW5Lgd4jb%2BiyHIilJTkEMqlD1fcoqPB2ZNuUImQSZho%2BbyUz%2BpHkuGRAjnHNnJV%5CnQwppZPDdkLB5h16k1A2dP0xoTObhgCAPD0IQTHLcsSYJulM90qeS6wPjSMZD2q%2Bg%5CnQUZ9%2BdMRi4tS9Yf19daYxD9gfH%2F5ZbDzrKeHT6iSJ%2FIAim2ZRY0F4fummVgwH%2Fq8%5CnbC2RNwr3yOrElOSy%2BIpCixD1UtIIw5rfVeEH3W%2F07dgGFdzinUiGAPxWIQa3TnKQ%5CnFzYts4ECgYEA8gCSgudma0o89DHf9OnRs2YBsN3uL0pKU9Plbrh1O5p1OHdg1H%2BD%5CnQUBG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signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response
{
            "website" : {
                "account":"jmcodeguard",
                "port":null,
                "container_size":0,
                "dir_path":"",
                "monitor_frequency":1,
                "provider":"ftp",
                "url":"www.codeguard.com",
                "owner_id":2,
                "id":17,
                "hostname":"rcloud-ftp.codeguard.com",
                "activated":false,
                "notifications_enabled":true
            }
        }
        

Edit Websites

This method is used to modify existing website records.

URI: /websites/<WEBSITE_ID>

Method: PUT

Optional Attributes
Example Request
http put 'https://api.codeguard.com/websites/12?oauth_consumer_key=Ezc2doao056bb177yan4kLugYJu7y6zRrf0BQuEs&oauth_nonce=1234&oauth_signature=vLy35yGcDDoMkayjI3Sn0Ko70Os%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1334612979&oauth_token=Arvlr5wtNgcFYks22Gnvf0k9VnW0gl7jNx3vnGaV&oauth_version=1.0'
        
Example Response
{
            "website" : {
                "account":"jmcodeguard",
                "port":null,
                "container_size":0,
                "dir_path":"",
                "monitor_frequency":1,
                "provider":"ftp",
                "url":"www.codeguard.com",
                "owner_id":2,
                "id":17,
                "hostname":"rcloud-ftp.codeguard.com",
                "activated":false,
                "notifications_enabled":true
            }
        }
        

Delete Websites

This method is used to delete existing CodeGuard Website resources. Deleting a Website resource will also delete all associated Database records.

URI: /websites/<id>

Method: DELETE

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X DELETE 'https://api.codeguard.com/websites/87866?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        

List Websites

This method will return all Website records owned by the requesting user.

URI: /websites

Method: GET

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET 'https://api.codeguard.com/websites?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response
[
            {
                "website" : {
                    "created_at" : "2013-06-13T17:09:30Z",
                    "updated_at" : "2013-06-13T17:09:30Z",
                    "disk_usage" : 0,
                    "monitor_frequency" : 0
                    "commit_id" : "",
                    "url" : "www.example1.com",
                    "owner_id" : 39,
                    "activated" : false,
                    "notifications_enabled" : true
                }
            },
            {
                "website" : {
                    "created_at" : "2013-07-13T17:10:30Z",
                    "updated_at" : "2013-07-13T17:05:30Z",
                    "disk_usage" : 0,
                    "monitor_frequency" : 0
                    "commit_id" : "",
                    "url" : "www.example2.com",
                    "owner_id" : 39,
                    "activated" : false,
                    "notifications_enabled" : true
                }
            }
        ]
        

Request Backup

This method will initiate an on-demand backup for a Website.

URI: /websites/<WEBSITE_ID>/request_backup

Method: POST

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/request_backup?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
            "status" : "success"
        }
        

Request Full Restore

This method will initiate a full restore for a Website. During this process the selected backup, specified as COMMIT_ID, will be compared against the live website. All necessary modifications will be made to return the running website to the state captured in the specified backup.

The desired backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/initiate_restore

Method: POST

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/initate_restore?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
            "status" : "success"
        }
        

Request Selective Restore

This method will initiate a restore of the specified files and directories for a Website. During this process the selected backup, specified as COMMIT_ID, will be used as the source of the selected content. The individual file and directory paths should be specified as a string of comma delimited paths. Directories must end with a trailing slash. For example: /path/to/directory/ and not /path/to/directory

The desired backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/restore_selected

Method: POST

Required Attributes

The request will not succeed without these attributes.

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json"  -d "paths=[\'/path_to_file.txt\', \'/path/to/folder/\']" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/restore_selected?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
            "status" : "success"
        }
        

Request Full Zip Download

This method will initiate the production of a zip file which contains the entire contents of the selected backup. During this process the selected backup, specified as COMMIT_ID, will be packaged as a single zip file and stored in Amazon S3. Upon completion, a perishable link will be provided to the customer so that they can retrieve the zip file. By default, these links expire after 1 week.

The desired backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/download

Method: POST

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/download?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
            "status" : "success"
        }
        

Request Selective Zip Download

This method will initiate the production of a zip file which contains the specified files and directories. During this process the selected backup, specified as COMMIT_ID, will be used as the source of the selected content, packaged as a single zip file and stored in Amazon S3. Upon completion, a perishable link will be provided to the customer so that they can retrieve the zip file. By default, these links expire after 1 week.

The individual file and directory paths should be specified as a string of comma delimited paths. Directories must end with a trailing slash. For example: /path/to/directory/ and not /path/to/directory

The desired backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/download_selected

Method: POST

Required Attributes

The request will not succeed without these attributes.

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json"  -d "paths=[\'/path_to_file.txt\', \'/path/to/folder/\']" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/download_selected?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
            "status" : "success"
        }
        

Browse Backup Content

This interface allows clients to browse the content of a particular backup. The response includes files, directories and their associated metadata as an array of entries. The requests can be scoped to an optional path parameter. If a path is not specified, the content of the root folder will be returned. During this process the selected backup, specified as COMMIT_ID, will be used as the source of the content.

The desired backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/browse

Method: GET

Required Attributes

None

Optional Attributes
Example Request
curl -v -H "Content-type: application/json"  -H "Accept: application/json" -X GET 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/browse?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
          "name":"public_html",
          "parent":"/home1/hgbackup",
          "owner":null,
          "group":null,
          "mode":null,
          "entries":[
              {
              "group":31304,
              "name":".ftpquota",
              "parent":"/home1/hgbackup/public_html",
              "size":15,
              "mode":384,
              "modified_at":"2014-11-15T07:35:24Z",
              "owner":31304
              },
              {
              "group":31304,
              "name":".htaccess",
              "parent":"/home1/hgbackup/public_html",
              "size":12893,
              "mode":420,
              "modified_at":"2014-02-24T19:41:02Z",
              "owner":31304
              }
            ]
        }
        

List DB Restore Points

Given a Website record and an associated backup, specified as COMMIT_ID, this interface will return a list of Database restore points that most closely match the level of content in the specified website backup.

The response will provide a DATABASE_ID keyed dictionary of associated Database records including the database_name. If they are available to restore, the Database commit_id will be included along with the backup_time timestamp for that particular backup. If the database is not available to restore, an error_message will be provided instead of the commit_id and backup_time.

The desired Website backup and corresponding COMMIT_ID can be located using the List Backups request.

URI: /websites/<WEBSITE_ID>/commits/<COMMIT_ID>/database_backup_commits

Method: GET

Required Attributes

None

Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json"  -H "Accept: application/json" -X GET 'https://api.codeguard.com/websites/973532/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/browse?oauth_consumer_key=u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc&oauth_nonce=1234&oauth_signature=JxkBWtFneUDx02ArD1ZBR7NGmWs%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1307966160&oauth_token=qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr&oauth_version=1.0'
        
Example Response

        {
          "5633":{
            "database_name":"dbbackup_wrdp14",
            "commit_id":"9b9eb63f1584b06913e178c37d15658e02bedacc",
            "backup_time":"July  1, 2017 -  4:01 am UTC",
            "error_message":""
          },
          "90334":{
            "database_name":"joomla_12",
            "commit_id":"",
            "backup_time":"",
            "error_message":"A restore is already in progress."
          }
        }