The Database
resource type represents a database backup within the CodeGuard application. A database belongs to a Website
.
Requests to the Database
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.
The following are the attributes associated with the Database
resource. Whether they are required or optional is specified in the sections that follow.
Unique numeric ID used to identify the database resource in the CodeGuard application.
This is the protocol to be used to connect to the host specified as hostname. Acceptable values for this field are mysql or mssql. Note: When using the 'mssql' provider, only direct authentication is permitted.
Numeric ID of the parent Website
record. If no website_id is provided, the Database
will not be associated with a Website
record.
Database Hostname or IP address.
The name of the target database.
Indicates whether or not the backup is enabled. Disabled resources will not be scheduled for backups.
Username which has access to the database_name database.
Password associated with account. Note: This parameter is only used during the create action. It is never returned by other API requests.
Server port number for use with the server_name. (Default: 3306 for MySQL, 1433 for MS SQL)
This service can has two modes: direct and ssh. The direct method will attempt to open a connection using a MySQL or MS SQL client on the specified server and port. The ssh method will create an SSH tunnel through server_name using the server_account and server_password credentials to connect to the database on server_name. Note: The following two attributes are required for SSH.
SSH username on server_address. Note: This field is only valid if the authenticationmode is ssh._
SSH password associated with server_account. Note: This field is only valid if the authenticationmode is ssh._
The ID of the most recent backup represented as a SHA-1 hash.
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.
The size in bytes of the database backup stored in the CodeGuard system.
The desired time of day for this backup to begin, in UTC.
This method is used to create new database backup records.
URI: /database_backups
Method: POST
The request will not succeed without these attributes.
http post 'https://api.codeguard.com/database_backups?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' website_id=184 server_address=dev.manuzak.com account=user password=password port=3306 database_name=test_restore server_account=user server_password=password authentication_mode=ssh
{
"database_backup":
{
"account":"user",
"authentication_mode":"direct",
"server_address":"dev.manuzak.com",
"disk_usage":0,
"database_name":"test_restore",
"backup_state":0,
"port":3306,
"commit_id":"",
"mysql_version":null,
"id":12,
"repo_size": 0,
"last_backup_status":null,
"disabled":false,
"activated":true,
"notifications_enabled":true,
"website_id":141
}
}
This method is used to display information about a single database backup record.
URI: /database_backups/<DATABASE_BACKUP_ID>
Method: GET
None
None
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET 'https://api.codeguard.com/websites/141/database_backups/12?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'
{
"database_backup":
{
"account":"user",
"authentication_mode":"direct",
"server_address":"dev.manuzak.com",
"disk_usage":0,
"database_name":"test_restore",
"backup_state":0,
"port":3306,
"commit_id":"",
"mysql_version":null,
"id":12,
"repo_size": 0,
"last_backup_status":null,
"disabled":false,
"activated":true,
"notifications_enabled":true,
"website_id":141
}
}
This method is used to modify existing database backup records.
URI: /database_backups/<DATABASE_BACKUP_ID>
Method: PUT
None
http put 'https://api.codeguard.com/database_backups/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'
{
"database_backup":
{
"account":"user",
"authentication_mode":"direct",
"server_address":"dev1.manuzak.com",
"disk_usage":0,
"database_name":"test_restore",
"backup_state":0,
"port":3306,
"commit_id":"",
"mysql_version":null,
"id":12,
"repo_size": 0,
"last_backup_status":null,
"disabled":false,
"activated":true,
"notifications_enabled":true,
"website_id":141
}
}
This method is used to delete existing CodeGuard Database
resources.
URI: /database_backups/<id>
Method: DELETE
None
None
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X DELETE 'https://api.codeguard.com/database_backups/3412?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'
This will display all Database
records owned by a user.
URI: /database_backups
Method: GET
None
None
http get 'https://api.codeguard.com/database_backups?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'
(
[0] => Array
(
[database_backup] => Array
(
[account] => db_user1
[authentication_mode] => direct
[website_id] => 1111
[server_address] => 192.168.1.1
[disk_usage] => 0
[database_name] => wordpress
[backup_state] => 0
[port] => 3306
[commit_id] =>
[mysql_version] => 5.1
[id] => 11
[repo_size] => 0
[mysqldump_version] => 5.1
[last_backup_status] =>
[disabled] => 0
[activated] => 1
[notifications_enabled] => 1
)
)
[1] => Array
(
[database_backup] => Array
(
[account] => db_user2
[authentication_mode] => direct
[website_id] => 1405
[server_address] => 10.0.222.3
[disk_usage] => 0
[database_name] => drupal
[backup_state] => 0
[port] => 3306
[commit_id] =>
[mysql_version] => 5.5
[id] => 18
[repo_size] => 0
[mysqldump_version] => 5.5
[last_backup_status] =>
[disabled] => 0
[activated] => 1
[notifications_enabled] => 1
)
)
)
This method will initiate an on-demand backup for a Database
.
URI: /websites/<WEBSITE_ID>/database_backups/<DATABASE_BACKUP_ID>/request_backup
Method: POST
None
None
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/database_backups/832332/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'
{
"status" : "success"
}
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>/database_backups/<DATABASE_BACKUP_ID>/commits/<COMMIT_ID>/download
Method: POST
None
None
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/database_backups/5612/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'
{
"message" : "200"
}
This method will initiate a full restore for a Database
. During this process the selected backup, specified as COMMIT_ID
, will be used to overwrite the existing, live database content. During this process tables are dropped, recreated and then repopulated with the data from the selected backup version.
The desired backup and corresponding COMMIT_ID
can be located using the List Backups request.
URI: /websites/<WEBSITE_ID>/database_backups/<DATABASE_BACKUP_ID>/commits/<COMMIT_ID>/initiate_restore
Method: POST
None
None
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST 'https://api.codeguard.com/websites/973532/database_backups/832332/commits/4a46f80fb145fc626fe4d6c730788fd10c69fbb7/initiate_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'
{
"status" : "success"
}