Commit 24a32034 authored by gisle's avatar gisle Committed by DamienMcKenna
Browse files

Issue #3121655 by DamienMcKenna, gisle: Link to Amazon S3 PHP class produces 404.

parent ed1a6c32
......@@ -15,6 +15,7 @@ Backup and Migrate 7.x-3.x-dev, xxxx-xx-xx
deprecated.
#3231913 by Andrei Haurukovich, DamienMcKenna: Phan scan notice: Argument 1
($value) is ($errors < 5) of type bool.
#3121655 by DamienMcKenna, gisle: Link to Amazon S3 PHP class produces 404.
Backup and Migrate 7.x-3.9, 2020-07-15
......
......@@ -22,14 +22,30 @@ OPTIONAL:
* To drop all tables before import, expand "Advanced options" panel under the
"Restore" and "Saved backups" tabs and tick the option.
* Enable token.module to allow token replacement in backup file names.
* To Backup to Amazon S3:
- Download the most recent version from:
* To backup to Amazon AWS S3 or compatible storage systems:
- Download the most recent version of the required library from:
https://github.com/tpyo/amazon-s3-php-class
- Rename the unzipped folder to "s3-php5-curl".
- Or clone it with command:
git clone https://github.com/tpyo/amazon-s3-php-class.git s3-php5-curl
- Rename the unzipped folder to s3-php5-curl
- This should create a directory named "s3-php5-curl".
- Place the directory inside the following directory: sites/all/libraries
- The library path should be "sites/all/libraries/s3-php5-curl/S3.php".
The most recent version of the library known to work is 0.5.1.
Note: The most recent version of the library known to work is 0.5.1.
Notes about Amazon AWS S3
-------------------------------------------------------------------------------
The library does not support Amazon AWS S3 signature SigV4. This signature has
been required in all AWS S3 regions launched after 2013, and will also required
for new buckets created after June 24, 2020 in all regions. For details, see:
https://aws.amazon.com/blogs/aws/amazon-s3-update-sigv2-deprecation-period-extended-modified/
This means that the choice of regions to back up to is limited.
Also see this issue:
https://www.drupal.org/project/backup_migrate/issues/3062823
Advanced settings
......
......@@ -14,6 +14,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
public $supported_ops = array('scheduled backup', 'manual backup', 'remote backup', 'restore', 'list files', 'configure', 'delete');
public $s3 = NULL;
public $cache_files = TRUE;
public $got_library = FALSE;
/**
* Save to to the s3 destination.
......@@ -81,8 +82,14 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
*/
public function edit_form() {
// Check for the library.
// @todo Moe this to a constructor.
$this->s3_object();
// Do not return the form if library is not found.
if (!$this->got_library) {
return array();
}
$form = parent::edit_form();
$form['scheme']['#type'] = 'value';
$form['scheme']['#value'] = 'https';
......@@ -162,9 +169,19 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
*
*/
public function s3_object() {
// Try to use libraries module if available to find the path.
$library_paths = array();
// Try to use the Libraries module if available to find the path.
if (function_exists('libraries_get_path')) {
$library_paths[] = libraries_get_path('s3-php5-curl');
// @todo Defne this using hook_libraries().
$path = libraries_get_path('s3-php5-curl');
if (!empty($path)) {
$library_paths[] = $path;
}
// If the library isn't defined, fall back to the default.
else {
$library_paths[] = 'sites/all/libraries/s3-php5-curl';
}
}
else {
$library_paths[] = 'sites/all/libraries/s3-php5-curl';
......@@ -183,10 +200,11 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
}
$this->s3 = new S3($this->dest_url['user'], $this->dest_url['pass'], FALSE, $host);
}
$this->got_library = TRUE;
return $this->s3;
}
}
drupal_set_message(t('Due to drupal.org code hosting policies, the S3 library needed to use an S3 destination is no longer distributed with this module. You must download the library from !link and place it in one of these locations: %locations.', array('%locations' => implode(', ', $library_paths), '!link' => l('http://undesigned.org.za/2007/10/22/amazon-s3-php-class', 'http://undesigned.org.za/2007/10/22/amazon-s3-php-class'))), 'error', FALSE);
drupal_set_message(t('A library is required to use an S3 destination. Please see <code>README.txt</code> for further instructions. The library could not be found in one of these locations: %locations.', array('%locations' => implode(', ', $library_paths))), 'error', FALSE);
return NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment