forked from rsnapshot/rsnapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsnapshot-HOWTO.en.html
1386 lines (1386 loc) · 60.9 KB
/
rsnapshot-HOWTO.en.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
<title>rsnapshot HOWTO</title>
<link href="http://www.xml-dev.com/blog/new.css" rel="stylesheet"
type="text/css" />
<meta content="DocBook XSL Stylesheets V1.64.1" name=
"generator" />
<meta name="description" content=
"rsnapshot is a filesystem backup utility based on rsync. Using rsnapshot, it is possible to take snapshots of your filesystems at different points in time. Using hard links, rsnapshot creates the illusion of multiple full backups, while only taking up the space of one full backup plus differences. When coupled with ssh, it is possible to take snapshots of remote filesystems as well. This document is a tutorial in the installation and configuration of rsnapshot." />
<meta xmlns="http://www.w3.org/1999/xhtml" content=
"Experimental LDP.XSL $Revision: 1.2 $" name="generator" />
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="article" lang="en">
<div class="titlepage">
<div>
<div>
<h1 class="title"><a name="N10001"></a>rsnapshot
HOWTO</h1>
</div>
<div>
<div class="author">
<h3 class="author"><span class=
"firstname">David</span> <span class=
"surname">Cantrell</span></h3>
<div class="affiliation">
<div class="address">
<p><span style="white-space: pre;"><tt class=
"email"><<a href=
"mailto:[email protected]">[email protected]</a>></tt></span></p>
</div>
</div>
</div>
</div>
<div>
<p class="pubdate">2004-01-20</p>
</div>
<!--<div>
<div class="revhistory">
<table summary="Revision history" width="100%" border=
"1">
<tr>
<th colspan="3" valign="top" align="left">
<b>Revision History</b></th>
</tr>
<tr>
<td align="left">Revision 1.2</td>
<td align="left">2006-10-06</td>
<td align="left">DC</td>
</tr>
<tr>
<td colspan="3" align="left">Clarified that prev.max is renamed to create the next level of backup;<br>changed most refs to Nathan to say David instead.</td>
</tr>
<tr>
<td align="left">Revision 1.0.0</td>
<td align="left">2005-01-31</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Updated for rsnapshot
1.2.0</td>
</tr>
<tr>
<td align="left">Revision 0.9.7</td>
<td align="left">2005-01-17</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Spelling corrections
submitted by Nicolas Kaiser</td>
</tr>
<tr>
<td align="left">Revision 0.9.6</td>
<td align="left">2004-12-13</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Misc. updates</td>
</tr>
<tr>
<td align="left">Revision 0.9.5</td>
<td align="left">2004-07-10</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Relicensed document
under GPL, instead of FDL</td>
</tr>
<tr>
<td align="left">Revision 0.9.4</td>
<td align="left">2004-07-02</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Added description of
proper crontab time settings</td>
</tr>
<tr>
<td align="left">Revision 0.9.3</td>
<td align="left">2004-06-11</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Misc. updates</td>
</tr>
<tr>
<td align="left">Revision 0.9.2</td>
<td align="left">2004-05-16</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Updated --link-dest
info</td>
</tr>
<tr>
<td align="left">Revision 0.9.1</td>
<td align="left">2004-01-20</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">Added --link-dest
info</td>
</tr>
<tr>
<td align="left">Revision 0.9</td>
<td align="left">2004-01-10</td>
<td align="left">NR</td>
</tr>
<tr>
<td colspan="3" align="left">First draft</td>
</tr>
</table>
</div>
</div>-->
<div>
<div class="abstract">
<p class="title"><b>Abstract</b></p>
<p>rsnapshot is a filesystem backup utility based on
rsync. Using rsnapshot, it is possible to take
snapshots of your filesystems at different points in
time. Using hard links, rsnapshot creates the illusion
of multiple full backups, while only taking up the
space of one full backup plus differences. When coupled
with ssh, it is possible to take snapshots of remote
filesystems as well. This document is a tutorial in the
installation and configuration of rsnapshot.</p>
</div>
</div>
</div>
<hr />
</div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="#intro">1.
Introduction</a></span></dt>
<dd>
<dl>
<dt><span class="sect2"><a href=
"#what_you_will_need">1.1. What you will
need</a></span></dt>
<dt><span class="sect2"><a href="#copyright">1.2.
Copyright and License</a></span></dt>
<dt><span class="sect2"><a href="#disclaimer">1.3.
Disclaimer</a></span></dt>
<dt><span class="sect2"><a href="#feedback">1.4.
Feedback</a></span></dt>
</dl>
</dd>
<dt><span class="sect1"><a href="#motivation">2.
Motivation</a></span></dt>
<dt><span class="sect1"><a href="#installation">3.
Installation</a></span></dt>
<dd>
<dl>
<dt><span class="sect2"><a href=
"#thirty_second_version">3.1. 30 second version (for
the impatient)</a></span></dt>
<dt><span class="sect2"><a href=
"#untar_the_source_code_package">3.2. Untar the source
code package</a></span></dt>
<dt><span class="sect2"><a href=
"#change_to_src_dir">3.3. Change to the source
directory</a></span></dt>
<dt><span class="sect2"><a href=
"#decide_where_to_install">3.4. Decide where you want
to install</a></span></dt>
<dt><span class="sect2"><a href=
"#run_the_configure_script">3.5. Run the configure
script</a></span></dt>
<dt><span class="sect2"><a href=
"#install_the_program">3.6. Install the
program</a></span></dt>
</dl>
</dd>
<dt><span class="sect1"><a href="#configuration">4.
Configuration</a></span></dt>
<dd>
<dl>
<dt><span class="sect2"><a href=
"#create_the_config_file">4.1. Create the config
file</a></span></dt>
<dt><span class="sect2"><a href=
"#where_to_go_for_more_info">4.2. Where to go for more
info</a></span></dt>
<dt><span class="sect2"><a href=
"#modifying_the_config_file">4.3. Modifying the config
file</a></span></dt>
<dt><span class="sect2"><a href=
"#testing_your_config_file">4.4. Testing your config
file</a></span></dt>
</dl>
</dd>
<dt><span class="sect1"><a href="#automation">5.
Automation</a></span></dt>
<dt><span class="sect1"><a href="#how_it_works">6. How it
works</a></span></dt>
<dt><span class="sect1"><a href="#restoring_backups">7.
Restoring backups</a></span></dt>
<dd>
<dl>
<dt><span class="sect2"><a href="#root_only">7.1. root
only</a></span></dt>
<dt><span class="sect2"><a href="#all_users">7.2. All
users</a></span></dt>
</dl>
</dd>
<dt><span class="sect1"><a href="#conclusion">8.
Conclusion</a></span></dt>
<dt><span class="sect1"><a href="#more_resources">9. More
resources</a></span></dt>
</dl>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a name=
"intro"></a>1. Introduction</h2>
</div>
</div>
</div>
<p>rsnapshot is a filesystem backup utility based on rsync.
Using rsnapshot, it is possible to take snapshots of your
filesystems at different points in time. Using hard links,
rsnapshot creates the illusion of multiple full backups,
while only taking up the space of one full backup plus
differences. When coupled with ssh, it is possible to take
snapshots of remote filesystems as well.</p>
<p>rsnapshot is written in Perl, and depends on rsync.
OpenSSH, GNU cp, GNU du, and the BSD logger program are also
recommended, but not required. All of these should be present
on most Linux systems. rsnapshot is written with the lowest
common denominator in mind. It only requires at minimum Perl
5.004 and rsync. As a result of this, it works on pretty much
any UNIX-like system you care to throw at it. It has been
successfully tested with Perl 5.004 through 5.8.2, on Debian,
Redhat, Fedora, Solaris, Mac OS X, FreeBSD, OpenBSD, NetBSD,
and IRIX.</p>
<p>The latest version of the program and this document can
always be found at <a href="http://www.rsnapshot.org/"
target="_top">http://www.rsnapshot.org/</a>.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"what_you_will_need"></a>1.1. What you
will need</h3>
</div>
</div>
</div>
<p>At a minimum: <i class="emphasis">perl, rsync</i></p>
<p>Optionally: <i class="emphasis">ssh, logger, GNU cp, GNU
du</i></p>
<p>Additionally, it will help if you have reasonably good
sysadmin skills.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"copyright"></a>1.2. Copyright and
License</h3>
</div>
</div>
</div>
<p>This document, rsnapshot HOWTO, is copyrighted (c) 2005
by Nathan Rosenquist, with some portions (c) 2006 David
Cantrell. You can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. A
copy of the license is available at <a href=
"http://www.gnu.org/copyleft/gpl.html" target=
"_top">http://www.gnu.org/copyleft/gpl.html</a>.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"disclaimer"></a>1.3. Disclaimer</h3>
</div>
</div>
</div>
<p>No liability for the contents of this document can be
accepted. Use the concepts, examples and information at
your own risk. There may be errors and inaccuracies, that
could be damaging to your system. Proceed with caution, and
although this is highly unlikely, the author(s) do not take
any responsibility.</p>
<p>All copyrights are held by their by their respective
owners, unless specifically noted otherwise. Use of a term
in this document should not be regarded as affecting the
validity of any trademark or service mark. Naming of
particular products or brands should not be seen as
endorsements.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"feedback"></a>1.4. Feedback</h3>
</div>
</div>
</div>
<p>Feedback is most certainly welcome for this document.
Send your additions, comments and criticisms to the
following email address : <tt class="email"><<a href=
"mailto:[email protected]">[email protected]</a>></tt>.</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a name=
"motivation"></a>2. Motivation</h2>
</div>
</div>
</div>
<p>I originally used Mike Rubel's shell scripts to do rsync
snapshots a while back. These worked very well, but there
were a number of things that I wanted to improve upon. I had
to write two shell scripts that were customized for my
server. If I wanted to change the number of intervals stored,
or the parts of the filesystem that were archived, that meant
manually editing these shell scripts. If I wanted to install
them on a different server with a different configuration,
this meant manually editing the scripts for the new server,
and hoping the logic and the sequence of operations was
correct. Also, I was doing all the backups locally, on a
single machine, on a single hard drive (just to protect from
dumb user mistakes like deleting files). Never the less, I
continued on with this system for a while, and it did work
very well.</p>
<p>Several months later, the IDE controller on my web server
failed horribly (when I typed <span><b class=
"command">/sbin/shutdown</b></span>, it said the command was
not found). I was then faced with what was in the back of my
mind all along: I had not been making regular remote backups
of my server, and the local backups were of no use to me
since the entire drive was corrupted. The reason I had only
been making sporadic, partial remote backups is that they
weren't automatic and effortless. Of course, this was no
one's fault but my own, but I got frustrated enough to write
a tool that would make automated remote snapshots so easy
that I wouldn't ever have to worry about them again. This
goal has long been reached, but work on rsnapshot still
continues as people submit patches, request features, and
ways are found to improve the program.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a name=
"installation"></a>3. Installation</h2>
</div>
</div>
</div>
<p>This section will walk you through the installation of
rsnapshot, step by step. This is not the only way to do it,
but it is a way that works and that is well documented. Feel
free to improvise if you know what you're doing.</p>
<p>This guide assumes you are installing rsnapshot 1.2.0 for
the first time. If you are upgrading from an earlier version,
please read the <tt class="filename">INSTALL</tt> file that
comes with the source distribution instead.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"thirty_second_version"></a>3.1. 30 second
version (for the impatient)</h3>
</div>
</div>
</div>
<pre class="screen">
<span><b class="command">./configure --sysconfdir=/etc</b></span>
<span><b class="command">su</b></span>
<span><b class="command">make install</b></span>
<span><b class=
"command">cp /etc/rsnapshot.conf.default /etc/rsnapshot.conf</b></span>
</pre>
<p>The rest of this section is the long version.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"untar_the_source_code_package"></a>3.2. Untar
the source code package</h3>
</div>
</div>
</div>
<pre class="screen">
<span><b class="command">tar xzvf rsnapshot-1.2.0.tar.gz</b></span>
</pre>
<p>If you don't have GNU <tt class="filename">tar</tt>, you
may have to do this in two steps instead:</p>
<pre class="screen">
<span><b class="command">gunzip rsnapshot-1.2.0.tar.gz</b></span>
<span><b class="command">tar xvf rsnapshot-1.2.0.tar</b></span>
</pre>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"change_to_src_dir"></a>3.3. Change to the
source directory</h3>
</div>
</div>
</div>
<pre class="screen">
<span><b class="command">cd rsnapshot-1.2.0/</b></span>
</pre>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"decide_where_to_install"></a>3.4. Decide
where you want to install</h3>
</div>
</div>
</div>
<p>By default, the installation procedure will install all
files under <tt class="filename">/usr/local</tt>. For this
tutorial, this will be OK except we will install the config
file under <tt class="filename">/etc</tt>.</p>
<p>We are assuming that <tt class="filename">rsync</tt>,
<tt class="filename">ssh</tt>, <tt class=
"filename">logger</tt>, and <tt class="filename">du</tt>
are all in your search path. If this is not the case, you
can specify the path to any of these programs using the
typical Autoconf <i class=
"parameter"><tt>--with-program=/path/to/program</tt></i>
syntax. For example, if Perl was in <tt class=
"filename">/opt/bin/perl</tt> and rsync was in <tt class=
"filename">/home/me/bin/rsync</tt>, you could run configure
like:</p>
<pre class="screen">
<span><b class=
"command">./configure --with-perl=/opt/bin/perl --with-rsync=/home/me/bin/rsync</b></span>
</pre>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"run_the_configure_script"></a>3.5. Run
the configure script</h3>
</div>
</div>
</div>
<p>This will poke and prod your system to figure out where
the various external programs that rsnapshot depends on
live. It also generates the Makefile that we will use to
install the program. The configure script accepts arguments
that can be used to tell it where to install the program,
and also where to find the supporting programs. For this
installation, the only non-default option we want is to put
the config file in the <tt class="filename">/etc</tt>
directory. To do this, run this command at the shell:</p>
<pre class="screen">
<span><b class="command">./configure --sysconfdir=/etc</b></span>
</pre>
<p>If all goes well, you're ready to install the program.
If there was a problem, it should be descriptive. Most
likely a problem would be the result of something that was
required and not found (like rsync or perl). If this
happens, you must figure out where the missing program is
located on your system, or install it if necessary. If you
know where it is but configure couldn't find it, you can
specify the path using the <i class=
"parameter"><tt>--with-program=/path/to/program</tt></i>
options described above.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"install_the_program"></a>3.6. Install the
program</h3>
</div>
</div>
</div>
<p>If you've followed these instructions so far, you will
have configured rsnapshot to be installed under <tt class=
"filename">/usr/local</tt>, with the config file in
<tt class="filename">/etc</tt>. Under these circumstances,
it will be necessary to become root to install the program.
Now is the time to do so. You will, of course, need the
root password to do this:</p>
<pre class="screen">
<span><b class="command">su</b></span>
</pre>
<p>This will prompt you for the root password.</p>
<p>Now, to install rsnapshot, run the following
command:</p>
<pre class="screen">
<span><b class="command">make install</b></span>
</pre>
<p>This will install rsnapshot with all the settings you
specified in the ./configure stage. If all goes well, you
will have the following files on your system:</p>
<p><tt class="filename">/usr/local/bin/rsnapshot</tt> The
rsnapshot program</p>
<p><tt class=
"filename">/usr/local/man/man1/rsnapshot.1</tt> Man
page</p>
<p><tt class="filename">/etc/rsnapshot.conf.default</tt>
The example config file</p>
<p>If you decide later that you don't want rsnapshot on
your system anymore, simply remove the files listed above,
or run <span><b class="command">make uninstall</b></span>
in the same source directory you installed from. Of course,
if you installed with different options, the location of
these files may be different.</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a name=
"configuration"></a>4. Configuration</h2>
</div>
</div>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"create_the_config_file"></a>4.1. Create
the config file</h3>
</div>
</div>
</div>
<p>In the install process, the config file is not created
or installed. However, a working example is provided that
you can copy. To copy the example config file into the
location rsnapshot will be looking for the real config
file:</p>
<pre class="screen">
<span><b class=
"command">cp /etc/rsnapshot.conf.default /etc/rsnapshot.conf</b></span>
</pre>
<p>As a general rule, you should avoid modifying <tt class=
"filename">/etc/rsnapshot.conf.default</tt>, simply because
it is a working example that you may wish to refer to
later. Also, if you perform an upgrade, the <tt class=
"filename">rsnapshot.conf.default</tt> file will always be
upgraded to the latest version, while your real config file
will be safe out of harm's way. Please note that if you run
<span><b class="command">make upgrade</b></span> during an
upgrade, your rsnapshot.conf may be modified slightly, and
the original will then be saved in <tt class=
"filename">rsnapshot.conf.backup</tt> in the same
directory.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"where_to_go_for_more_info"></a>4.2. Where
to go for more info</h3>
</div>
</div>
</div>
<p>The <tt class="filename">rsnapshot.conf</tt> config file
is well commented, and much of it should be fairly
self-explanatory. For a full reference of all the various
options, please consult the rsnapshot man page. Type:</p>
<pre class="screen">
<span><b class="command">man rsnapshot</b></span>
</pre>
<p>This will give you the complete documentation. However,
it assumes that you already know what you're doing to a
certain extent. If you just want to get something up and
running, this tutorial is a better place to start. If your
system can't find the man page, <tt class=
"filename">/usr/local/man</tt> probably isn't in your
$MANPATH environmental variable. This is beyond the scope
of this document, but if it isn't working for you, you can
always read the newest man page on the rsnapshot web site
at <a href="http://www.rsnapshot.org/" target=
"_top">http://www.rsnapshot.org/</a></p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name=
"modifying_the_config_file"></a>4.3. Modifying
the config file</h3>
</div>
</div>
</div>
<p>In this example, we will be using the <tt class=
"filename">/.snapshots/</tt> directory to hold the
filesystem snapshots. This is referred to as the
“<span class="quote">snapshot
root</span>â€. Feel free to put this anywhere
you have lots of free disk space. However, the examples in
this document assume you have not changed this parameter,
so you will have to substitute this in your commands if you
put it somewhere else.</p>
<p>Also please note that fields are separated by tabs, not
spaces. The reason for this is so it's easier to specify
file paths with spaces in them.</p>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"cmd_cp"></a>4.3.1. cmd_cp</h4>
</div>
</div>
</div>
<p>If enabled, the <i class="emphasis">cmd_cp</i>
parameter should contain the path to the GNU <tt class=
"filename">cp</tt> program on your filesystem. If you are
using Linux, be sure to uncomment this by removing the
hash mark (#) in front of it. If you are using BSD,
Solaris, IRIX, or most other UNIX variants, you should
leave this commented out.</p>
<p>What makes GNU <tt class="filename">cp</tt> so special
is that unlike the traditional UNIX <tt class=
"filename">cp</tt>, it has the ability to make recursive
“<span class=
"quote">copies</span>†of directories as hard
links.</p>
<p>If you don't have GNU <tt class="filename">cp</tt>,
there is a subroutine in rsnapshot that somewhat
approximates this functionality (although it won't
support more esoteric files such as device nodes, FIFOs,
sockets, etc). This gets followed up by another call to
rsync, which transfers the remaining special files, if
any. In this way, rsnapshot can support all file types on
every platform.</p>
<p>The rule of thumb is that if you're on a Linux system,
leave <i class="emphasis">cmd_cp</i> enabled. If you
aren't on a Linux system, leave <i class=
"emphasis">cmd_cp</i> disabled. There are reports of GNU
<tt class="filename">cp</tt> working on BSD and other
non-Linux platforms, but there have also been some cases
where problems have been encountered. If you enable
<i class="emphasis">cmd_cp</i> on a non-Linux platform,
please let the mailing list know how it worked out for
you.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"cmd_rsync"></a>4.3.2. cmd_rsync</h4>
</div>
</div>
</div>
<p>The <i class="emphasis">cmd_rsync</i> parameter must
not be commented out, and it must point to a working
version of <tt class="filename">rsync</tt>. If it
doesn't, the program just will not work at all.</p>
<p>Please note that if you are using IRIX, there is
another program named <tt class="filename">rsync</tt>
that is different than the
“<span class="quote">real</span>â€
<tt class="filename">rsync</tt> most people know of. If
you're on an IRIX machine, you should double check
this.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"cmd_ssh"></a>4.3.3. cmd_ssh</h4>
</div>
</div>
</div>
<p>If you have <tt class="filename">ssh</tt> installed on
your system, you will want to uncomment the <i class=
"emphasis">cmd_ssh</i> parameter. By enabling <tt class=
"filename">ssh</tt>, you can take snapshots of any number
of remote systems. If you don't have <tt class=
"filename">ssh</tt>, or plan to only take snapshots of
the local filesystem, you may safely leave this commented
out.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"cmd_logger"></a>4.3.4. cmd_logger</h4>
</div>
</div>
</div>
<p>The <i class="emphasis">cmd_logger</i> parameter
specifies the path to the <tt class=
"filename">logger</tt> program. <tt class=
"filename">logger</tt> is a command line interface to
syslog. See the <tt class="filename">logger</tt> man page
for more details. <tt class="filename">logger</tt> should
be a standard part of most UNIX-like systems. It appears
to have remained unchanged since about 1993, which is
good for cross-platform stability. If you comment out
this parameter, it will disable syslog support in
rsnapshot. It is recommended that you leave this
enabled.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"cmd_du"></a>4.3.5. cmd_du</h4>
</div>
</div>
</div>
<p>The <i class="emphasis">cmd_du</i> parameter specifies
the path to the <tt class="filename">du</tt> program.
<tt class="filename">du</tt> is a command line tool that
reports on disk usage. rsnapshot uses <tt class=
"filename">du</tt> to generate reports about the actual
amount of disk space taken up, which is otherwise
difficult to estimate because of all the hard links.</p>
<p>If you comment this out, rsnapshot will try to use the
version of <tt class="filename">du</tt> it finds in your
path, if possible. The GNU version of <tt class=
"filename">du</tt> is recommended, since it has the best
selection of features, and supports the most options. The
BSD version also seems to work, although it doesn't
support the <span><b class="command">-h</b></span> flag.
Solaris <span><b class="command">du</b></span> does not
work at all, because it doesn't support the
<span><b class="command">-c</b></span> parameter.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"link_dest"></a>4.3.6. link_dest</h4>
</div>
</div>
</div>
<p>If you have <tt class="filename">rsync</tt> version
2.5.7 or later, you may want to enable this. With
<i class="emphasis">link_dest</i> enabled, rsnapshot
relies on rsync to create recursive hard links,
overriding GNU cp in most, but not all, cases. With
<i class="emphasis">link_dest</i> enabled, every single
file on your system can be backed up in one pass, on any
operating system. To get the most out of rsnapshot on
non-Linux platforms, <i class="emphasis">link_dest</i>
should be enabled. Be advised, however, that if a remote
host is unavailable during a backup, rsnapshot will take
an extra step and roll back the files from the previous
backup. Using GNU cp, this would not be necessary.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"interval"></a>4.3.7. interval</h4>
</div>
</div>
</div>
<p>rsnapshot has no idea how often you want to take
snapshots. Everyone's backup scheme may be different. In
order to specify how much data to save, you need to tell
rsnapshot which “<span class=
"quote">intervals</span>†to keep, and how
many of each. An interval, in the context of the
rsnapshot config file, is a unit of time measurement.
These can actually be named anything (as long as it's
alphanumeric, and not a reserved word), but by convention
we will call ours <i class="emphasis">hourly</i> and
<i class="emphasis">daily</i>. In this example, we want
to take a snapshot every four hours, or six times a day
(these are the <i class="emphasis">hourly</i> intervals).
We also want to keep a second set, which are taken once a
day, and stored for a week (or seven days). This happens
to be the default, so as you can see the config file
reads:</p>
<pre class="screen">
interval hourly 6
interval daily 7
</pre>
<p>It also has some other entries, but you can either
ignore them or comment them out for now.</p>
<p>Please note that the <i class="emphasis">hourly</i>
interval is specified first. This is very important. The
first <i class="emphasis">interval</i> line is assumed to
be the smallest unit of time, with each additional line
getting successively larger. Thus, if you add a <i class=
"emphasis">yearly</i> interval, it should go at the
bottom, and if you add a <i class="emphasis">minutes</i>
interval, it should go before hourly. It's also worth
noting that the snapshots get
“<span class="quote">pulled
up</span>†from the smallest interval to the
largest. In this example, the daily snapshots get pulled
from the oldest hourly snapshot, not directly from the
main filesystem.</p>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"backup"></a>4.3.8. backup</h4>
</div>
</div>
</div>
<p>Please note that the destination paths specified here
are based on the assumption that the <i class=
"emphasis">--relative</i> flag is being passed to
<tt class="filename">rsync</tt> via the <i class=
"emphasis">rsync_long_args</i> parameter. If you are
installing for the first time, this is the default
setting. If you upgraded from a previous version, please
read the <tt class="filename">INSTALL</tt> file that came
with the source distribution for more information.</p>
<p>This is the section where you tell rsnapshot what
files you actually want to back up. You put a
“<span class=
"quote">backup</span>†parameter first,
followed by the full path to the directory or network
path you're backing up. The third column is the relative
path you want to back up to inside the snapshot root.
Let's look at an example:</p>
<pre class="screen">
backup /etc/ localhost/
</pre>
<p>In this example, <i class="emphasis">backup</i> tells
us it's a backup point. <tt class="filename">/etc/</tt>
is the full path to the directory we want to take
snapshots of, and <tt class="filename">localhost/</tt> is
a directory inside the <i class=
"emphasis">snapshot_root</i> we're going to put them in.
Using the word <i class="emphasis">localhost</i> as the
destination directory is just a convention. You might
also choose to use the server's fully qualified domain
name instead of <i class="emphasis">localhost</i>. If you
are taking snapshots of several machines on one dedicated
backup server, it's a good idea to use their various
hostnames as directories to keep track of which files
came from which server.</p>
<p>In addition to full paths on the local filesystem, you
can also backup remote systems using <tt class=
"filename">rsync</tt> over <tt class="filename">ssh</tt>.
If you have <tt class="filename">ssh</tt> installed and
enabled (via the <i class="emphasis">cmd_ssh</i>
parameter), you can specify a path like:</p>
<pre class="screen">
backup [email protected]:/etc/ example.com/
</pre>
<p>This behaves fundamentally the same way, but you must
take a few extra things into account.</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>The ssh daemon must be running on
example.com</p>
</li>
<li>
<p>You must have access to the account you specify
the remote machine, in this case the root user on
example.com.</p>
</li>
<li>
<p>You must have key-based logins enabled for the
root user at example.com, without passphrases. If
you wanted to perform backups as another user, you
could specify the other user instead of root for
the source (i.e. [email protected]). Please note that
allowing remote logins with no passphrase is a
security risk that may or may not be acceptable in
your situation. Make sure you guard access to the
backup server very carefully! For more information
on how to set this up, please consult the ssh man
page, or a tutorial on using ssh public and private
keys. You will find that the key based logins are
better in many ways, not just for rsnapshot but for
convenience and security in general. One thing you
can do to mitigate the potential damage from a
backup server breach is to create alternate users
on the client machines with uid and gid set to 0,
but with a more restrictive shell such as
scponly.</p>
</li>
<li>
<p>This backup occurs over the network, so it may
be slower. Since this uses <tt class=
"filename">rsync</tt>, this is most noticeable
during the first backup. Depending on how much your
data changes, subsequent backups should go much,
much faster since <i class="emphasis">rsync</i>
only sends the differences between files.</p>
</li>
</ul>
</div>
</div>
<div class="sect3" lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name=
"backup_script"></a>4.3.9. backup_script</h4>
</div>
</div>
</div>
<p>With this parameter, the second column is the full
path to an executable backup script, and the third column
is the local path you want to store it in (just like with
the "backup" parameter). For example:</p>
<pre class="screen">
backup_script /usr/local/bin/backup_pgsql.sh localhost/postgres/
</pre>
<p>In this example, rsnapshot will run the script
<tt class="filename">/usr/local/bin/backup_pgsql.sh</tt>
in a temp directory, then sync the results into the
<tt class="filename">localhost/postgres/</tt> directory
under the snapshot root. You can find the backup_pgsql.sh
example script in the <tt class="filename">utils/</tt>
directory of the source distribution. Feel free to modify
it for your system.</p>
<p>Your backup script simply needs to dump out the
contents of whatever it does into its current working
directory. It can create as many files and/or directories
as necessary, but it should not put its files in any
pre-determined path. The reason for this is that
rsnapshot creates a temp directory, changes to that
directory, runs the backup script, and then syncs the
contents of the temp directory to the local path you
specified in the third column. A typical backup script
would be one that archives the contents of a database. It
might look like this:</p>
<pre class="screen">
<span><b class="command">#!/bin/sh
/usr/bin/mysqldump -uroot mydatabase > mydatabase.sql
/bin/chmod 644 mydatabase.sql</b></span>
</pre>
<p>There are several example scripts in the <tt class=
"filename">utils/</tt> directory of the rsnapshot source
distribution to give you more ideas.</p>
<p>Make sure the destination path you specify is unique.
The backup script will completely overwrite anything in
the destination path, so if you tried to specify the same
destination twice, you would be left with only the files
from the last script. Fortunately, rsnapshot will try to
prevent you from doing this when it reads the config
file.</p>
<p>Please remember that these backup scripts will be
invoked as the user running rsnapshot. In our example,
this is root. Make sure your backup scripts are owned by
root, and not writable by anyone else. If you fail to do
this, anyone with write access to these backup scripts