-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase-cleanup.php
More file actions
32 lines (25 loc) · 869 Bytes
/
database-cleanup.php
File metadata and controls
32 lines (25 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
* @file
* Delete all User-generated database backups in configured environments.
*/
require_once 'vendor/autoload.php';
require_once 'config.php';
use Acquia\Cloud\Api\CloudApiClient;
$cloudapi = CloudApiClient::factory(array(
'username' => getenv('ACQUIA_CLOUD_USERNAME'),
'password' => getenv('ACQUIA_CLOUD_PASSWORD'),
));
foreach ($database_cleanup_environments as $environment) {
// Get a list of all an environment's database backups.
$backups = $cloudapi->databaseBackups($site, $environment, $database);
$count = 0;
foreach ($backups as $backup) {
if ($backup->type() == 'ondemand') {
$backup_id = $backup->id();
$cloudapi->deleteDatabaseBackup($site, $environment, $database, $backup->id());
$count++;
}
}
printf("Deleted %d ondemand database backups in %s environment.\n", $count, $environment);
}