2014-01-09 46 views
0

我發現這些腳本導出/導入的CouchDB:虧本 zebooka/couchdb-dumpCouchDB的導入/導出與PHP腳本

我到哪裏這個開始?用法說,運行與-h標誌每個腳本,但我「不能確定這是什麼意思?

任何人都可以發佈關於如何使用這些腳本的例子嗎?

+0

爲什麼要使用腳本爲什麼不只是手動複製文件或使用複製? – AVK

+0

-h僅供參考,例如: /my/bin/couchdb-dump.php -H localhost -p 5984 -d test> dump.json – Zebooka

回答

0

正好有副本了。未安裝的時候CouchDB的另一臺服務器上的數據對於任何人要做到這一點,這裏是爲我工作的解決方案:

<?php 
// *** PUT YOUR CONNECTION TO COUCH HERE, try using: https://github.com/dready92/PHP-on-Couch 

$client->limit(9999999999999); 
$client->include_docs(TRUE); 
$all_docs = $client->getAllDocs(); 
$filename = date('Ymdhis').'.json'; 

// *** BE SURE to include $path variable for the location of the file 
$path = ''; 
$destination = $path . $filename; 
$file = fopen($destination, "w+"); 
fputs($file,json_encode($all_docs)); 
fclose($file); 
$zip = new ZipArchive(); 
$zip->open($destination.'.zip', ZipArchive::CREATE); 
$zip->addFile($destination); 
$zip->close(); 
unlink($destination);?>