]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - doc/html/Copy-an-existing-installation-over-SSH-and-serve-it-locally/index.html
doc: rename "datastore hacks" -> "various hacks", move example scripts to gist.github...
[github/shaarli/Shaarli.git] / doc / html / Copy-an-existing-installation-over-SSH-and-serve-it-locally / index.html
1 <!DOCTYPE html>
2 <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3 <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4 <head>
5 <meta charset="utf-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
9
10 <link rel="shortcut icon" href="../img/favicon.ico">
11 <title>Copy an existing installation over SSH and serve it locally - Shaarli Documentation</title>
12 <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
13
14 <link rel="stylesheet" href="../css/theme.css" type="text/css" />
15 <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
16 <link rel="stylesheet" href="../css/highlight.css">
17 <link href="../github-markdown.css" rel="stylesheet">
18
19 <script>
20 // Current page data
21 var mkdocs_page_name = "Copy an existing installation over SSH and serve it locally";
22 var mkdocs_page_input_path = "Copy-an-existing-installation-over-SSH-and-serve-it-locally.md";
23 var mkdocs_page_url = "/Copy-an-existing-installation-over-SSH-and-serve-it-locally/";
24 </script>
25
26 <script src="../js/jquery-2.1.1.min.js"></script>
27 <script src="../js/modernizr-2.8.3.min.js"></script>
28 <script type="text/javascript" src="../js/highlight.pack.js"></script>
29
30 </head>
31
32 <body class="wy-body-for-nav" role="document">
33
34 <div class="wy-grid-for-nav">
35
36
37 <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
38 <div class="wy-side-nav-search">
39 <a href=".." class="icon icon-home"> Shaarli Documentation</a>
40 <div role="search">
41 <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
42 <input type="text" name="q" placeholder="Search docs" />
43 </form>
44 </div>
45 </div>
46
47 <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
48 <ul class="current">
49
50
51 <li class="toctree-l1">
52
53 <a class="" href="..">Home</a>
54 </li>
55
56 <li class="toctree-l1">
57
58 <span class="caption-text">Setup</span>
59 <ul class="subnav">
60 <li class="">
61
62 <a class="" href="../Download-and-Installation/">Download and Installation</a>
63 </li>
64 <li class="">
65
66 <a class="" href="../Upgrade-and-migration/">Upgrade and migration</a>
67 </li>
68 <li class="">
69
70 <a class="" href="../Server-requirements/">Server requirements</a>
71 </li>
72 <li class="">
73
74 <a class="" href="../Server-configuration/">Server configuration</a>
75 </li>
76 <li class="">
77
78 <a class="" href="../Server-security/">Server security</a>
79 </li>
80 <li class="">
81
82 <a class="" href="../Shaarli-configuration/">Shaarli configuration</a>
83 </li>
84 <li class="">
85
86 <a class="" href="../Plugins/">Plugins</a>
87 </li>
88 </ul>
89 </li>
90
91 <li class="toctree-l1">
92
93 <span class="caption-text">Docker</span>
94 <ul class="subnav">
95 <li class="">
96
97 <a class="" href="../Docker-101/">Docker 101</a>
98 </li>
99 <li class="">
100
101 <a class="" href="../Shaarli-images/">Shaarli images</a>
102 </li>
103 <li class="">
104
105 <a class="" href="../Reverse-proxy-configuration/">Reverse proxy configuration</a>
106 </li>
107 <li class="">
108
109 <a class="" href="../Docker-resources/">Docker resources</a>
110 </li>
111 </ul>
112 </li>
113
114 <li class="toctree-l1">
115
116 <span class="caption-text">Usage</span>
117 <ul class="subnav">
118 <li class="">
119
120 <a class="" href="../Features/">Features</a>
121 </li>
122 <li class="">
123
124 <a class="" href="../Bookmarklet/">Bookmarklet</a>
125 </li>
126 <li class="">
127
128 <a class="" href="../Browsing-and-searching/">Browsing and searching</a>
129 </li>
130 <li class="">
131
132 <a class="" href="../Firefox-share/">Firefox share</a>
133 </li>
134 <li class="">
135
136 <a class="" href="../RSS-feeds/">RSS feeds</a>
137 </li>
138 <li class="">
139
140 <a class="" href="../REST-API/">REST API</a>
141 </li>
142 </ul>
143 </li>
144
145 <li class="toctree-l1">
146
147 <span class="caption-text">How To</span>
148 <ul class="subnav">
149 <li class="">
150
151 <a class="" href="../Backup,-restore,-import-and-export/">Backup, restore, import and export</a>
152 </li>
153 <li class=" current">
154
155 <a class="current" href="./">Copy an existing installation over SSH and serve it locally</a>
156 <ul class="subnav">
157
158 </ul>
159 </li>
160 <li class="">
161
162 <a class="" href="../Create-and-serve-multiple-Shaarlis-(farm)/">Create and serve multiple Shaarlis (farm)</a>
163 </li>
164 <li class="">
165
166 <a class="" href="../Download-CSS-styles-from-an-OPML-list/">Download CSS styles from an OPML list</a>
167 </li>
168 <li class="">
169
170 <a class="" href="../Datastore-hacks/">Datastore hacks</a>
171 </li>
172 </ul>
173 </li>
174
175 <li class="toctree-l1">
176
177 <a class="" href="../Troubleshooting/">Troubleshooting</a>
178 </li>
179
180 <li class="toctree-l1">
181
182 <span class="caption-text">Development</span>
183 <ul class="subnav">
184 <li class="">
185
186 <a class="" href="../Development-guidelines/">Development guidelines</a>
187 </li>
188 <li class="">
189
190 <a class="" href="../Continuous-integration-tools/">Continuous integration tools</a>
191 </li>
192 <li class="">
193
194 <a class="" href="../GnuPG-signature/">GnuPG signature</a>
195 </li>
196 <li class="">
197
198 <a class="" href="../Coding-guidelines/">Coding guidelines</a>
199 </li>
200 <li class="">
201
202 <a class="" href="../Directory-structure/">Directory structure</a>
203 </li>
204 <li class="">
205
206 <a class="" href="../3rd-party-libraries/">3rd party libraries</a>
207 </li>
208 <li class="">
209
210 <a class="" href="../Plugin-System/">Plugin System</a>
211 </li>
212 <li class="">
213
214 <a class="" href="../Release-Shaarli/">Release Shaarli</a>
215 </li>
216 <li class="">
217
218 <a class="" href="../Versioning-and-Branches/">Versioning and Branches</a>
219 </li>
220 <li class="">
221
222 <a class="" href="../Security/">Security</a>
223 </li>
224 <li class="">
225
226 <a class="" href="../Static-analysis/">Static analysis</a>
227 </li>
228 <li class="">
229
230 <a class="" href="../Theming/">Theming</a>
231 </li>
232 <li class="">
233
234 <a class="" href="../Unit-tests/">Unit tests</a>
235 </li>
236 </ul>
237 </li>
238
239 <li class="toctree-l1">
240
241 <span class="caption-text">About</span>
242 <ul class="subnav">
243 <li class="">
244
245 <a class="" href="../FAQ/">FAQ</a>
246 </li>
247 <li class="">
248
249 <a class="" href="../Community-&-Related-software/">Community & Related software</a>
250 </li>
251 </ul>
252 </li>
253
254 </ul>
255 </div>
256 &nbsp;
257 </nav>
258
259 <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
260
261
262 <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
263 <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
264 <a href="..">Shaarli Documentation</a>
265 </nav>
266
267
268 <div class="wy-nav-content">
269 <div class="rst-content">
270 <div role="navigation" aria-label="breadcrumbs navigation">
271 <ul class="wy-breadcrumbs">
272 <li><a href="..">Docs</a> &raquo;</li>
273
274
275
276 <li>How To &raquo;</li>
277
278
279
280 <li>Copy an existing installation over SSH and serve it locally</li>
281 <li class="wy-breadcrumbs-aside">
282
283 <a href="https://github.com/shaarli/Shaarli/edit/master/docs/Copy-an-existing-installation-over-SSH-and-serve-it-locally.md"
284 class="icon icon-github"> Edit on GitHub</a>
285
286 </li>
287 </ul>
288 <hr/>
289 </div>
290 <div role="main">
291 <div class="section">
292
293 <p>Example bash script:</p>
294 <pre><code class="bash">#!/bin/bash
295 #Description: Copy a Shaarli installation over SSH/SCP, serve it locally with php-cli
296 #Will create a local-shaarli/ directory when you run it, backup your Shaarli there, and serve it locally.
297 #Will NOT download linked pages. It's just a directly usable backup/copy/mirror of your Shaarli
298 #Requires: ssh, scp and a working SSH access to the server where your Shaarli is installed
299 #Usage: ./local-shaarli.sh
300 #Author: nodiscc (nodiscc@gmail.com)
301 #License: MIT (http://opensource.org/licenses/MIT)
302 set -o errexit
303 set -o nounset
304
305 ##### CONFIG #################
306 #The port used by php's local server
307 php_local_port=7431
308
309 #Name of the SSH server and path where Shaarli is installed
310 #TODO: pass these as command-line arguments
311 remotehost=&quot;my.ssh.server&quot;
312 remote_shaarli_dir=&quot;/var/www/shaarli&quot;
313
314
315 ###### FUNCTIONS #############
316 _main() {
317 _CBSyncShaarli
318 _CBServeShaarli
319 }
320
321 _CBSyncShaarli() {
322 remote_temp_dir=$(ssh $remotehost mktemp -d)
323 remote_ssh_user=$(ssh $remotehost whoami)
324 ssh -t &quot;$remotehost&quot; sudo cp -r &quot;$remote_shaarli_dir&quot; &quot;$remote_temp_dir&quot;
325 ssh -t &quot;$remotehost&quot; sudo chown -R &quot;$remote_ssh_user&quot;:&quot;$remote_ssh_user&quot; &quot;$remote_temp_dir&quot;
326 scp -rq &quot;$remotehost&quot;:&quot;$remote_temp_dir&quot; local-shaarli
327 ssh &quot;$remotehost&quot; rm -r &quot;$remote_temp_dir&quot;
328 }
329
330 _CBServeShaarli() {
331 #TODO: allow serving a previously downloaded Shaarli
332 #TODO: ask before overwriting local copy, if it exists
333 cd local-shaarli/
334 php -S localhost:${php_local_port}
335 echo &quot;Please go to http://localhost:${php_local_port}&quot;
336 }
337
338
339 ##### MAIN #################
340
341 _main
342 </code></pre>
343
344 <p>This outputs:</p>
345 <pre><code class="bash">$ ./local-shaarli.sh
346 PHP 5.6.0RC4 Development Server started at Mon Sep 1 21:56:19 2014
347 Listening on http://localhost:7431
348 Document root is /home/user/local-shaarli/shaarli
349 Press Ctrl-C to quit.
350
351 [Mon Sep 1 21:56:27 2014] ::1:57868 [200]: /
352 [Mon Sep 1 21:56:27 2014] ::1:57869 [200]: /index.html
353 [Mon Sep 1 21:56:37 2014] ::1:57881 [200]: /...
354 </code></pre>
355
356 </div>
357 </div>
358 <footer>
359
360 <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
361
362 <a href="../Create-and-serve-multiple-Shaarlis-(farm)/" class="btn btn-neutral float-right" title="Create and serve multiple Shaarlis (farm)">Next <span class="icon icon-circle-arrow-right"></span></a>
363
364
365 <a href="../Backup,-restore,-import-and-export/" class="btn btn-neutral" title="Backup, restore, import and export"><span class="icon icon-circle-arrow-left"></span> Previous</a>
366
367 </div>
368
369
370 <hr/>
371
372 <div role="contentinfo">
373 <!-- Copyright etc -->
374
375 </div>
376
377 Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
378 </footer>
379
380 </div>
381 </div>
382
383 </section>
384
385 </div>
386
387 <div class="rst-versions" role="note" style="cursor: pointer">
388 <span class="rst-current-version" data-toggle="rst-current-version">
389
390 <a href="https://github.com/shaarli/Shaarli" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
391
392
393 <span><a href="../Backup,-restore,-import-and-export/" style="color: #fcfcfc;">&laquo; Previous</a></span>
394
395
396 <span style="margin-left: 15px"><a href="../Create-and-serve-multiple-Shaarlis-(farm)/" style="color: #fcfcfc">Next &raquo;</a></span>
397
398 </span>
399 </div>
400 <script src="../js/theme.js"></script>
401
402 </body>
403 </html>