public/wordpress/wp-content/plugins/backupbuddy/destinations/s33/init.php
/* multipart_cleanup()
	 *
	 * S3 does NOT automatically clean up failed or expired multipart chunk files so clean up for them.
	 *
	 */
multipart_cleanup()
S3 does NOT automatically clean up failed or expired multipart chunk files so clean up for them.
multipart_cleanup () S3 does NOT automatically clean up failed or expired multipart chunk files so clean up for them .
public static function multipart_cleanup( $settings ) {
		$settings = self::_init( $settings ); 
		pb_backupbuddy::status( 'details', 'AWS Multipart cleanup beginning.' );
		$backupDetectPrefix = 'backup-';
		if ( isset( $settings['live_mode'] ) && ( '1' == $settings['live_mode'] ) ) {
			$backupDetectPrefix = '';
		}
		try {
			$response = self::$_client->listMultipartUploads( array(
				'Bucket' => $settings['bucket'],
				'prefix' => $settings['directory'] . $backupDetectPrefix,
			) );
		} Catch( Exception $e ) {
			return self::_error( 'Error #84397849347: Unable to list existing multipart uploads. Details: `' . $e->getMessage() . '`' );
		}
		if ( pb_backupbuddy::$options['log_level'] == '3' ) { 
			pb_backupbuddy::status( 'details', 'Multipart upload check retrieved. Found `' . count( $response['Uploads'] ) . '` multipart uploads in progress / stalled. Full logging mode details: `' . print_r( $response, true ) . '`' );
		} else {
			pb_backupbuddy::status( 'details', 'Multipart upload check retrieved. Found `' . count( $response['Uploads'] ) . '` multipart uploads in progress / stalled. Old BackupBuddy parts will be cleaned up (if any found) ...' );
		}
		foreach( (array)$response['Uploads'] as $upload ) {
			if ( pb_backupbuddy::$options['log_level'] == '3' ) { 
				pb_backupbuddy::status( 'details', 'Checking upload (full logging mode): ' . print_r( $upload, true ) );
			}
			$initiated = strtotime( $upload['Initiated'] );
			if ( pb_backupbuddy::$options['log_level'] == '3' ) { 
				pb_backupbuddy::status( 'details', 'Multipart Chunked Upload(s) detected in progress. Full logging age: `' . pb_backupbuddy::$format->time_ago( $initiated ) . '`.' );
			}
			if ( ( $initiated + self::MAX_AGE_MULTIPART_UPLOADS ) < time() ) {
				pb_backupbuddy::status( 'details', 'Aborting stalled Multipart Chunked Upload with ID `' . $upload->UploadId . '` of age `' . pb_backupbuddy::$format->time_ago( $initiated ) . '`.' );
				try {
					self::$_client->abortMultipartUpload( array(
						'Bucket' => $settings['bucket'],
						'Key' => $upload['Key'],
						'UploadId' => $upload['UploadId']
					) );
					pb_backupbuddy::status( 'details', 'Abort success.' );
				} Catch( Exception $e ) {
					pb_backupbuddy::status( 'error', 'Stalled Multipart Chunked abort of file `' . $upload['Key'] . '` with ID `' . $upload['UploadId'] . '` FAILED. Manually abort it. Details: `' . $e->getMessage() . '`.' );
				}
			} else {
				if ( pb_backupbuddy::$options['log_level'] != '3' ) { 
					pb_backupbuddy::status( 'details', 'Multipart Chunked Uploads not aborted as not too old.' );
				}
			}
		} 
		pb_backupbuddy::status( 'details', 'AWS Multipart cleanup finished.' );
		return true;
	}
public static function multipart_cleanup ( $ settings ) { $ settings = self :: _init ( $ settings ) ; pb_backupbuddy :: status ( 'details' , 'AWS Multipart cleanup beginning.' ) ; $ backupDetectPrefix = 'backup-' ; if ( isset ( $ settings [ 'live_mode' ] ) && ( '1' == $ settings [ 'live_mode' ] ) ) { $ backupDetectPrefix = '' ; } try { $ response = self :: $ _client -> listMultipartUploads ( array ( 'Bucket' => $ settings [ 'bucket' ] , 'prefix' => $ settings [ 'directory' ] . $ backupDetectPrefix , ) ) ; } Catch ( Exception $ e ) { return self :: _error ( 'Error #84397849347: Unable to list existing multipart uploads. Details: `' . $ e -> getMessage ( ) . '`' ) ; } if ( pb_backupbuddy :: $ options [ 'log_level' ] == '3' ) { pb_backupbuddy :: status ( 'details' , 'Multipart upload check retrieved. Found `' . count ( $ response [ 'Uploads' ] ) . '` multipart uploads in progress / stalled. Full logging mode details: `' . print_r ( $ response , true ) . '`' ) ; } else { pb_backupbuddy :: status ( 'details' , 'Multipart upload check retrieved. Found `' . count ( $ response [ 'Uploads' ] ) . '` multipart uploads in progress / stalled. Old BackupBuddy parts will be cleaned up (if any found) ...' ) ; } foreach ( ( array ) $ response [ 'Uploads' ] as $ upload ) { if ( pb_backupbuddy :: $ options [ 'log_level' ] == '3' ) { pb_backupbuddy :: status ( 'details' , 'Checking upload (full logging mode): ' . print_r ( $ upload , true ) ) ; } $ initiated = strtotime ( $ upload [ 'Initiated' ] ) ; if ( pb_backupbuddy :: $ options [ 'log_level' ] == '3' ) { pb_backupbuddy :: status ( 'details' , 'Multipart Chunked Upload(s) detected in progress. Full logging age: `' . pb_backupbuddy :: $ format -> time_ago ( $ initiated ) . '`.' ) ; } if ( ( $ initiated + self :: MAX_AGE_MULTIPART_UPLOADS ) < time ( ) ) { pb_backupbuddy :: status ( 'details' , 'Aborting stalled Multipart Chunked Upload with ID `' . $ upload -> UploadId . '` of age `' . pb_backupbuddy :: $ format -> time_ago ( $ initiated ) . '`.' ) ; try { self :: $ _client -> abortMultipartUpload ( array ( 'Bucket' => $ settings [ 'bucket' ] , 'Key' => $ upload [ 'Key' ] , 'UploadId' => $ upload [ 'UploadId' ] ) ) ; pb_backupbuddy :: status ( 'details' , 'Abort success.' ) ; } Catch ( Exception $ e ) { pb_backupbuddy :: status ( 'error' , 'Stalled Multipart Chunked abort of file `' . $ upload [ 'Key' ] . '` with ID `' . $ upload [ 'UploadId' ] . '` FAILED. Manually abort it. Details: `' . $ e -> getMessage ( ) . '`.' ) ; } } else { if ( pb_backupbuddy :: $ options [ 'log_level' ] != '3' ) { pb_backupbuddy :: status ( 'details' , 'Multipart Chunked Uploads not aborted as not too old.' ) ; } } } pb_backupbuddy :: status ( 'details' , 'AWS Multipart cleanup finished.' ) ; return true ; }
multipart_cleanup()
 S3 does NOT automatically clean up failed or expired multipart chunk files so clean up for them.
multipart_cleanup () S3 does NOT automatically clean up failed or expired multipart chunk files so clean up for them .
// Handles formatting & sanitizing settings. // Full logging enabled. // Loop through each incomplete multipart upload. // Full logging enabled. //if ( FALSE !== stristr( $upload['Key'], $backupDetectPrefix ) ) { // BackupBuddy backup file. // Full logging enabled. // If too old then cancel it. // Full logging NOT enabled. //} // end foreach.