You've already forked minio-cookbook
mirror of
https://github.com/astaxie/cookbook.git
synced 2025-08-08 09:42:04 +03:00
Doc: added aws-sdk for ruby and python and modified existing doc. (#70)
This commit is contained in:
committed by
Harshavardhana
parent
1b1d0fb757
commit
f1b5ae761a
@@ -32,3 +32,5 @@ Note: You can also refer to [Awesome Minio](https://github.com/minio/awesome-min
|
|||||||
- [How to use Cyberduck with Minio](./docs/how-to-use-cyberduck-with-minio.md)
|
- [How to use Cyberduck with Minio](./docs/how-to-use-cyberduck-with-minio.md)
|
||||||
- [How to use AWS SDK for PHP with Minio Server](./docs/aws-sdk-for-php-with-minio.md)
|
- [How to use AWS SDK for PHP with Minio Server](./docs/aws-sdk-for-php-with-minio.md)
|
||||||
- [How to use AWS SDK for Go with Minio Server](./docs/aws-sdk-for-go-with-minio.md)
|
- [How to use AWS SDK for Go with Minio Server](./docs/aws-sdk-for-go-with-minio.md)
|
||||||
|
- [How to use AWS SDK for Python with Minio Server](./docs/aws-sdk-for-python-with-minio.md)
|
||||||
|
- [How to use AWS SDK for Ruby with Minio Server](./docs/aws-sdk-for-ruby-with-minio.md)
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
`aws-sdk-go` is the official AWS SDK for the Go programming language. In this recipe we will learn how to use `aws-sdk-go` with Minio server.
|
`aws-sdk-go` is the official AWS SDK for the Go programming language. In this recipe we will learn how to use `aws-sdk-go` with Minio server.
|
||||||
|
|
||||||
|
|
||||||
## 1. Prerequisites
|
## 1. Prerequisites
|
||||||
|
|
||||||
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
||||||
@@ -11,7 +10,6 @@ Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
|||||||
|
|
||||||
Install ``aws-sdk-go`` from AWS SDK for Go official docs [here](https://aws.amazon.com/sdk-for-go/)
|
Install ``aws-sdk-go`` from AWS SDK for Go official docs [here](https://aws.amazon.com/sdk-for-go/)
|
||||||
|
|
||||||
|
|
||||||
## 3. Example
|
## 3. Example
|
||||||
|
|
||||||
Please replace ``Endpoint``,``Credentials``, ``Bucket`` with your local setup in this ``example.go`` file.
|
Please replace ``Endpoint``,``Credentials``, ``Bucket`` with your local setup in this ``example.go`` file.
|
||||||
@@ -39,7 +37,7 @@ func main() {
|
|||||||
|
|
||||||
// Configure to use Minio Server
|
// Configure to use Minio Server
|
||||||
s3Config := &aws.Config{
|
s3Config := &aws.Config{
|
||||||
Credentials: credentials.NewStaticCredentials("H5K8172RVM311Q2XFEHX", "5bRnl3DGhNM+fRBMxOii11k8iT78cNSIfoqnJfwC", ""),
|
Credentials: credentials.NewStaticCredentials("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""),
|
||||||
Endpoint: aws.String("http://localhost:9000"),
|
Endpoint: aws.String("http://localhost:9000"),
|
||||||
Region: aws.String("us-east-1"),
|
Region: aws.String("us-east-1"),
|
||||||
DisableSSL: aws.Bool(true),
|
DisableSSL: aws.Bool(true),
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
`aws-sdk-php` is the official AWS SDK for the PHP programming language. In this recipe we will learn how to use `aws-sdk-php` with Minio server.
|
`aws-sdk-php` is the official AWS SDK for the PHP programming language. In this recipe we will learn how to use `aws-sdk-php` with Minio server.
|
||||||
|
|
||||||
|
|
||||||
## 1. Prerequisites
|
## 1. Prerequisites
|
||||||
|
|
||||||
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
||||||
@@ -11,14 +10,12 @@ Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
|||||||
|
|
||||||
Install `aws-sdk-php` from AWS SDK for PHP official docs [here](https://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html)
|
Install `aws-sdk-php` from AWS SDK for PHP official docs [here](https://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html)
|
||||||
|
|
||||||
|
|
||||||
## 3. Example
|
## 3. Example
|
||||||
|
|
||||||
Please replace ``endpoint``,``credentials``, ``Bucket`` with your local setup in this ``example.php`` file.
|
Please replace ``endpoint``,``key``, ``secret``, ``Bucket`` with your local setup in this ``example.php`` file.
|
||||||
|
|
||||||
Example below shows putObject and getObject operations on Minio server using aws-sdk-php.
|
Example below shows putObject and getObject operations on Minio server using aws-sdk-php.
|
||||||
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -32,8 +29,8 @@ $s3 = new Aws\S3\S3Client([
|
|||||||
'region' => 'us-east-1',
|
'region' => 'us-east-1',
|
||||||
'endpoint' => 'http://localhost:9000',
|
'endpoint' => 'http://localhost:9000',
|
||||||
'credentials' => [
|
'credentials' => [
|
||||||
'key' => 'H5K8172RVM311Q2XFEHX',
|
'key' => 'YOUR-ACCESSKEYID',
|
||||||
'secret' => '5bRnl3DGhNM+fRBMxOii11k8iT78cNSIfoqnJfwC',
|
'secret' => 'YOUR-SECRETACCESSKEY',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -57,7 +54,6 @@ echo $retrive['Body'];
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 4. Run the Program
|
## 4. Run the Program
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
54
docs/aws-sdk-for-python-with-minio.md
Normal file
54
docs/aws-sdk-for-python-with-minio.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# How to use AWS SDK for Python with Minio Server [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
`aws-sdk-php` is the official AWS SDK for the PHP programming language. In this recipe we will learn how to use `aws-sdk-php` with Minio server.
|
||||||
|
|
||||||
|
## 1. Prerequisites
|
||||||
|
|
||||||
|
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
||||||
|
|
||||||
|
## 2. Installation
|
||||||
|
|
||||||
|
Install `aws-sdk-python` from AWS SDK for Python official docs [here](https://aws.amazon.com/sdk-for-python/)
|
||||||
|
|
||||||
|
## 3. Example
|
||||||
|
|
||||||
|
Please replace ``endpoint_url``,``aws_access_key_id``, ``aws_secret_access_key``, ``Bucket`` and ``Object`` with your local setup in this ``example.py`` file.
|
||||||
|
|
||||||
|
Example below shows upload and download object operations on Minio server using aws-sdk-python.
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
#!/usr/bin/env/python
|
||||||
|
import boto3
|
||||||
|
from botocore.client import Config
|
||||||
|
|
||||||
|
|
||||||
|
s3 = boto3.resource('s3',
|
||||||
|
endpoint_url='http://localhost:9000',
|
||||||
|
aws_access_key_id='YOUR-ACCESSKEYID',
|
||||||
|
aws_secret_access_key='YOUR-SECRETACCESSKEY',
|
||||||
|
config=Config(signature_version='s3v4'),
|
||||||
|
region_name='us-east-1')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# upload a file from local file system '/home/john/piano.mp3' to bucket 'songs' with 'piano.mp3' as the object name.
|
||||||
|
s3.Bucket('songs').upload_file('piano.mp3', '/home/john/piano.mp3')
|
||||||
|
|
||||||
|
# download the object 'piano.mp3' from the bucket 'songs' and save it to local FS as /tmp/classical.mp3
|
||||||
|
s3.Bucket('songs').download_file('piano.mp3', '/tmp/classical.mp3')
|
||||||
|
|
||||||
|
print "Downloaded 'piano.mp3' as 'classical.mp3'. "
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Run the Program
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ python example.py
|
||||||
|
Downloaded 'piano.mp3' as 'classical.mp3'.
|
||||||
|
```
|
||||||
|
## 5. Explore Further
|
||||||
|
|
||||||
|
* [Minio Python Library for Amazon S3](https://docs.minio.io/docs/python-client-quickstart-guide)
|
61
docs/aws-sdk-for-ruby-with-minio.md
Normal file
61
docs/aws-sdk-for-ruby-with-minio.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# How to use AWS SDK for Ruby with Minio Server [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
`aws-sdk` is the official AWS SDK for the Ruby programming language. In this recipe we will learn how to use `aws-sdk` for Ruby with Minio server.
|
||||||
|
|
||||||
|
## 1. Prerequisites
|
||||||
|
|
||||||
|
Install Minio Server from [here](http://docs.minio.io/docs/minio).
|
||||||
|
|
||||||
|
## 2. Installation
|
||||||
|
|
||||||
|
Install `aws-sdk` for Ruby from official docs [here](https://aws.amazon.com/sdk-for-ruby/)
|
||||||
|
|
||||||
|
## 3. Example
|
||||||
|
|
||||||
|
Please replace ``endpoint``,``access_key_id``, ``secret_access_key``, ``Bucket`` and ``Object`` with your local setup in this ``example.rb`` file.
|
||||||
|
|
||||||
|
Example below shows put_object() and get_object() operations on Minio server using `aws-sdk Ruby`.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
require 'aws-sdk'
|
||||||
|
|
||||||
|
Aws.config.update(
|
||||||
|
endpoint: 'http://localhost:9000',
|
||||||
|
access_key_id: 'YOUR-ACCESSKEYID',
|
||||||
|
secret_access_key: 'YOUR-SECRETACCESSKEY',
|
||||||
|
force_path_style: true,
|
||||||
|
region: 'us-east-1'
|
||||||
|
)
|
||||||
|
|
||||||
|
rubys3_client = Aws::S3::Client.new
|
||||||
|
|
||||||
|
# put_object operation
|
||||||
|
|
||||||
|
rubys3_client.put_object(
|
||||||
|
key: 'testobject',
|
||||||
|
body: 'Hello from Minio!!',
|
||||||
|
bucket: 'testbucket',
|
||||||
|
content_type: 'text/plain'
|
||||||
|
)
|
||||||
|
|
||||||
|
# get_object operation
|
||||||
|
|
||||||
|
rubys3_client.get_object(
|
||||||
|
bucket: 'testbucket',
|
||||||
|
key: 'testobject',
|
||||||
|
response_target: 'download_testobject'
|
||||||
|
)
|
||||||
|
|
||||||
|
print "Downloaded 'testobject' as 'download_testobject'. "
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Run the Program
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ruby example.rb
|
||||||
|
Downloaded 'testobject' as 'download_testobject'.
|
||||||
|
```
|
||||||
|
## 5. Explore Further
|
||||||
|
|
||||||
|
* [RoR Resume Uploader App](https://docs.minio.io/docs/ror-resume-uploader-app)
|
@@ -7,45 +7,24 @@ In this recipe we will learn how to store MongoDB backups in Minio Server.
|
|||||||
|
|
||||||
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
||||||
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
||||||
* Know where the MongoDB backups reside in the local filesystem.
|
* MongoDB official [doc](https://docs.mongodb.com/).
|
||||||
|
|
||||||
|
|
||||||
## 2. Recipe Steps
|
## 2. Configuration Steps
|
||||||
|
|
||||||
In this recipe, we will use https://play.minio.io:9000 which is aliased to play. Feel free to use play server for testing and development. Access credentials shown in this example are open to public.
|
Minio server is running using alias ``m1``. Follow Minio client complete guide [here](https://docs.minio.io/docs/minio-client-complete-guid) for details. MongoDB backups are stored in ``mongobkp`` directory.
|
||||||
Replace with your own access credentials when running this example in your environment.
|
|
||||||
|
|
||||||
### Step 1: Create a bucket.
|
### Create a bucket.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mb m1/mongobkp
|
||||||
$ mc mb play/mongobkp
|
Bucket created successfully ‘m1/mongobkp’.
|
||||||
Bucket created successfully ‘play/mongobkp’.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Mirror local backup to Minio server.
|
### Continuously mirror local backup to Minio server.
|
||||||
|
|
||||||
|
Continuously mirror ``mongobkp`` folder recursively to Minio. Read more on ``mc mirror`` [here](https://docs.minio.io/docs/minio-client-complete-guide#mirror)
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mirror --force --remove --watch mongobkp/ m1/mongobkp
|
||||||
$ mc mirror mongobkp/ play/mongobkp
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Automate
|
|
||||||
|
|
||||||
The above recipe can be automated easily. Change the bash script below to your own directories and PATHS as needed. Set up a cron to run this task as needed.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
#FileName: Minimongobkp.sh & has executable permissions.
|
|
||||||
|
|
||||||
LocalBackupPath="/home/miniouser/mongobkp"
|
|
||||||
MinioBucket="play/mongobkp"
|
|
||||||
MCPATH="/home/miniouser/go/bin/mc"
|
|
||||||
|
|
||||||
$MCPATH - -quiet mirror $LocalBackupPath $MinioBucket
|
|
||||||
|
|
||||||
```
|
|
||||||
|
@@ -7,43 +7,25 @@ In this recipe we will learn how to store MySQL backups in Minio Server.
|
|||||||
|
|
||||||
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
||||||
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
||||||
* Know where the MySQL backups reside in the local filesystem.
|
* MySQL official [doc](https://dev.mysql.com/doc/)
|
||||||
|
|
||||||
## 2. Recipe Steps
|
## 2. Configuration Steps
|
||||||
|
|
||||||
Access credentials shown in this example belong to https://play.minio.io:9000.
|
Minio server is running using alias ``m1``. Follow Minio client complete guide [here](https://docs.minio.io/docs/minio-client-complete-guid) for details. MySQL backups are stored in ``mongobkp`` directory.
|
||||||
These credentials are open to public. Feel free to use this service for testing and development. Replace with your own Minio keys in deployment.
|
|
||||||
|
|
||||||
### Step 1: Create a bucket.
|
|
||||||
|
### Create a bucket.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mb m1/mysqlbkp
|
||||||
$ mc mb play/mysqlbkp
|
Bucket created successfully ‘m1/mysqlbkp’.
|
||||||
Bucket created successfully ‘play/mysqlbkp’.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Mirror mysqlbkup directory where the backup files reside to Minio server.
|
### Continuously mirror local backup to Minio server.
|
||||||
|
|
||||||
|
Continuously mirror ``mysqlbkp`` folder recursively to Minio. Read more on ``mc mirror`` [here](https://docs.minio.io/docs/minio-client-complete-guide#mirror)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mirror --force --remove --watch mysqlbkp/ m1/mysqlbkp
|
||||||
$ mc mirror mysqlbkp/ play/mysqlbkp
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Automate
|
|
||||||
|
|
||||||
The above recipe can be automated easily. Change the bash script below to your own directories and PATHS as needed. Set up a cron to run this task as needed.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
# Filename: minio-mysql-bkp.sh & has executable permissions.
|
|
||||||
|
|
||||||
LOCAL_BACKUP_PATH="/home/miniouser/mysqlbkp"
|
|
||||||
MINIO_BUCKET="play/mysqlbkp"
|
|
||||||
MC_PATH="/home/miniouser/go/bin/mc"
|
|
||||||
|
|
||||||
$MC_PATH - -quiet mirror $LOCAL_BACKUP_PATH $MINIO_BUCKET
|
|
||||||
|
|
||||||
```
|
|
||||||
|
@@ -6,43 +6,26 @@ In this recipe you will learn how to store PostgreSQL backups in Minio Server.
|
|||||||
|
|
||||||
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
* Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide).
|
||||||
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
* Install Minio Server from [here](https://docs.minio.io/docs/minio ).
|
||||||
* Know where the PostgreSQL backups reside in the local filesystem.
|
* PostgreSQL official [doc](https://www.postgresql.org/docs/).
|
||||||
|
|
||||||
## 2. Recipe Steps
|
## 2. Configuration Steps
|
||||||
|
|
||||||
In this recipe, we will use https://play.minio.io:9000 which is aliased to play. Feel free to use play server for testing and development. Access credentials shown in this example are open to public.
|
Minio server is running using alias ``m1``. Follow Minio client complete guide [here](https://docs.minio.io/docs/minio-client-complete-guid) for details. PostgreSQL backups are stored in ``pgsqlbkp`` directory.
|
||||||
Replace with your own access credentials when running this example in your environment.
|
|
||||||
|
|
||||||
### Step 1: Create a bucket:
|
### Create a bucket.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mb m1/pgsqlbkp
|
||||||
$ mc mb play/pgsqlbkp
|
Bucket created successfully ‘m1/pgsqlbkp’.
|
||||||
Bucket created successfully ‘play/pgsqlbkp’.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Mirror local backup to Minio server:
|
### Continuously mirror local backup to Minio server.
|
||||||
|
|
||||||
|
Continuously mirror ``pgsqlbkp`` folder recursively to Minio. Read more on ``mc mirror`` [here](https://docs.minio.io/docs/minio-client-complete-guide#mirror)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc mirror --force --remove --watch pgsqlbkp/ m1/pgsqlbkp
|
||||||
$ mc mirror pgsqlbkp/ play/pgsqlbkp
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Automate
|
|
||||||
|
|
||||||
The above recipe can be automated easily. Change the bash script below to your own directories and PATHS as needed. Set up a cron to run this task as needed.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
#FileName: Miniopgsqlbkp.sh & has executable permissions.
|
|
||||||
|
|
||||||
LocalBackupPath="/home/miniouser/pgsqlbkp"
|
|
||||||
MinioBucket="play/pgsqlbkp"
|
|
||||||
MCPATH="/home/miniouser/go/bin/mc"
|
|
||||||
|
|
||||||
$MCPATH - -quiet mirror $LocalBackupPath $MinioBucket
|
|
||||||
|
|
||||||
```
|
|
||||||
|
Reference in New Issue
Block a user