[ 
https://issues.apache.org/jira/browse/SOLR-7583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14559530#comment-14559530
 ] 

Greg Solovyev commented on SOLR-7583:
-------------------------------------


Downloading a zipped snapshot:

http://solr-host:solr-port/collection-name/replication?command=downloadbackup&name=snaphostname&wt=filestream

{code:java}
    InputStream stream = null;
    URL url = new URL(requestURL);
    stream = url.openStream();
    FastInputStream is = new FastInputStream((InputStream) stream);  
    String fileName = "downloaded." + backupName + ".zip";
    String savePath = 
createTempDir().resolve(fileName).toAbsolutePath().toString();
    File outFile = new File(savePath);
    FileOutputStream fos = new FileOutputStream(outFile);
    Long totalRead = 0L;
    try {
      byte[] longbytes = new byte[8];
      is.readFully(longbytes);
      Long fileSize = readLong(longbytes);
      while(fileSize > totalRead) {
        //store bytes representing packet size here
        byte[] intbytes = new byte[4]; 
        //read packet size
        is.readFully(intbytes);
        int packetSize = readInt(intbytes);
        //read the packet
        byte[] buf = new byte[packetSize];
        is.readFully(buf, 0, packetSize);
        fos.write(buf);
        fos.flush();
        totalRead+=(long)packetSize;
      }
    } finally  {
      //close streams
      IOUtils.closeQuietly(is);
      fos.close();      
    }
{code}


> API to download snapshot files/restore via upload
> -------------------------------------------------
>
>                 Key: SOLR-7583
>                 URL: https://issues.apache.org/jira/browse/SOLR-7583
>             Project: Solr
>          Issue Type: Improvement
>          Components: SolrCloud
>            Reporter: Greg Solovyev
>         Attachments: SOLR-7583.patch, SOLR-7583.patch
>
>
> What we are looking for:
> SolrCloud and Solr should have APIs to download a snapshot via HTTP. 
> For single node Solr, this API will find a snapshot and stream it back over 
> HTTP. For SolrCloud, this API will find a Replica that has the snapshot with 
> requested name and stream the snapshot from that replica. Since there are 
> multiple files inside a snapshot, the API should probably zip the snapshot 
> folder before sending it back to the client.
> Why we need this:
> this will allow us to create and fetch fully contained archives of customer 
> data where each backup archive will contain Solr index as well as other 
> customer data (DB, metadata, files, etc).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to