2014-01-09 118 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);?>