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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>simplesnap</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><H1
><A
NAME="AEN1"
></A
>simplesnap</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN14"
></A
><H2
>Name</H2
>simplesnap -- Simple and powerful way to send ZFS snapshots across a
network</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN17"
></A
><H2
>Synopsis</H2
><P
><B
CLASS="COMMAND"
>simplesnap</B
> [<CODE
CLASS="OPTION"
>--sshcmd</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>COMMAND</I
></TT
>] [<CODE
CLASS="OPTION"
>--wrapcmd</CODE
> <TT
CLASS="REPLACEABLE"
><I
>COMMAND</I
></TT
>] [<CODE
CLASS="OPTION"
>--local</CODE
>] [<CODE
CLASS="OPTION"
>--backupdataset</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>DATASET</I
></TT
>
[<CODE
CLASS="OPTION"
>--datasetdest</CODE
> <TT
CLASS="REPLACEABLE"
><I
>DEST</I
></TT
>]] <CODE
CLASS="OPTION"
>--store</CODE
> <TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
> <CODE
CLASS="OPTION"
>--setname</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>NAME</I
></TT
> <CODE
CLASS="OPTION"
>--host</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>HOST</I
></TT
> </P
><P
><B
CLASS="COMMAND"
>simplesnap</B
> <CODE
CLASS="OPTION"
>--check</CODE
> <TT
CLASS="REPLACEABLE"
><I
>TIMEFRAME</I
></TT
> <CODE
CLASS="OPTION"
>--store</CODE
> <TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
> <CODE
CLASS="OPTION"
>--setname</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>NAME</I
></TT
> [<CODE
CLASS="OPTION"
>--host</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>HOST</I
></TT
>]</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN57"
></A
><H2
>Description</H2
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is a simple way to send ZFS snapshots across a
network. Although it can serve many purposes, its primary goal
is to manage backups from one ZFS filesystem to a backup
filesystem also running ZFS, using incremental backups to
minimize network traffic and disk usage.
</P
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>FLEXIBLE</I
></SPAN
>; it is designed to
perfectly compliment snapshotting tools, permitting rotating
backups with arbitrary retention periods. It lets multiple
machines back up a single target, lets one machine back up
multiple targets, and keeps it all straight.
</P
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>EASY</I
></SPAN
>; there is no
configuration file needed. One ZFS property is available to
exclude datasets/filesystems. ZFS datasets are automatically
discovered on machines being backed up.
</P
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>SAFE</I
></SPAN
>; it is robust in the
face of interrupted transfers, and needs little help to keep
running.
</P
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>SECURE</I
></SPAN
>; unlike many similar
tools, it does not require full root access to the machines
being backed up. It runs only a small wrapper as root, and the
wrapper has only three commands it implements.
</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN73"
></A
><H3
>Feature List</H3
><P
> Besides the above, <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>:
</P
><P
></P
><UL
><LI
><P
> Does one thing and does it well. It is designed to be used with
a snapshot auto-rotator on both ends (such as zfSnap). simplesnap
will transfer snapshots made by other tools, but will not destroy
them on either end.
</P
></LI
><LI
><P
> Requires ssh public key authorization to the host being backed up,
but does not require permission to run arbitrary commands. It has
a wrapper to run on the backup host, written in bash, which accepts
only three operations and performs them simply. It is suitable for
a locked-down authorized_keys file.
</P
></LI
><LI
><P
> Creates minimal snapshots for its own internal purposes, generally
leaving no more than 1 or 2 per dataset, and reaps them
automatically without touching others.
</P
></LI
><LI
><P
> Is a small program, easily audited. In fact, most of the code is devoted to sanity-checking, security, and error
checking.
</P
></LI
><LI
><P
> Automatically discovers what datasets to back up from the remote.
Uses a user-defined zfs property to exclude filesystems that should
not be backed up.
</P
></LI
><LI
><P
> Logs copiously to syslog on all hosts involved in backups.
</P
></LI
><LI
><P
> Intelligently supports a single machine being backed up by multiple
backup hosts, or onto multiple sets of backup media (when, for
instance, backup media is cycled into offsite storage)
</P
></LI
></UL
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN92"
></A
><H3
>Method of Operation</H3
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>'s operation is very simple.
</P
><P
> The <B
CLASS="COMMAND"
>simplesnap</B
> program runs on the machine
that stores the backups -- we'll call it the backuphost.
There is a restricted remote command wrapper called
<B
CLASS="COMMAND"
>simplesnapwrap</B
> that runs on the machine
being backed up -- we'll call it the activehost.
<B
CLASS="COMMAND"
>simplesnapwrap</B
> is never invoked directly by
the end-user; it is always called remotely by
<B
CLASS="COMMAND"
>simplesnap</B
>.
</P
><P
> With <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>, the backuphost always connects to the
activehost -- never the other way round.
</P
><P
> <B
CLASS="COMMAND"
>simplesnap</B
> runs in the backuphost, and
first connects to the <B
CLASS="COMMAND"
>simplesnapwrap</B
> on the
activehost and asks it for a
list of the ZFS datasets ("listfs" operation). <B
CLASS="COMMAND"
>simplesnapwrap</B
>
responds with a list of all ZFS datasets that were not flagged for
exclusion.
</P
><P
> Next, <B
CLASS="COMMAND"
>simplesnap</B
> connects back to <B
CLASS="COMMAND"
>simplesnapwrap</B
> once for each dataset
to be backed up -- the "sendback" operation. <B
CLASS="COMMAND"
>simplesnap</B
> passes along
to it only two things: the setname and the dataset
(filesystem) name.
</P
><P
> <B
CLASS="COMMAND"
>simplesnapwrap</B
> looks to see if there is an existing simplesnap
snapshot corresponding to that <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>. If not, it creates one and
sends it as a full, non-incremental backup. That completes the job
for that dataset.
</P
><P
> If there is an existing snapshot for that <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>, simplesnapwrap
creates a new one, constructing the snapshot name containing a
timestamp and the <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>, then sends an incremental, using the oldest
snapshot from that setname as the basis for zfs send -I.
</P
><P
> After the backuphost has observed <B
CLASS="COMMAND"
>zfs receive</B
> exiting without error,
it contacts <B
CLASS="COMMAND"
>simplesnapwrap</B
> once more and requests the "reap"
operation. This cleans up the old snapshots for the given <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>,
leaving only the most recent. This is a separate operation in
<B
CLASS="COMMAND"
>simplesnapwrap</B
> ensuring that even if the transmission is interrupted,
still it will be OK in the end because <B
CLASS="COMMAND"
>zfs receive -F</B
> is used, and the
data will come across next time.
</P
><P
> The idea is that some system like <B
CLASS="COMMAND"
>zfSnap</B
> will be used on both ends to
make periodic snapshots and clean them up. One can use careful prefix
names with zfSnap to use different prefixes on each activehost, and
then implement custom cleanup rules with -F on the holderhost.
</P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN125"
></A
><H2
>Quick Start</H2
><P
> This section will describe how a first-time <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> user
can get up and running quickly. It assumes you already have
<SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> installed and working on your system. If not,
please follow the instructions in the
<TT
CLASS="FILENAME"
>INSTALL.txt</TT
> file in the source
distribution.
</P
><P
> As above, I will refer to the machine storing the backups as the
"backuphost" and the machine being backed up as the
"activehost".
</P
><P
> First, on the backuphost, as root, generate an ssh keypair that
will be used exclusively for <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>.
</P
><P
> <B
CLASS="COMMAND"
>ssh-keygen -t rsa -f ~/.ssh/id_rsa_simplesnap</B
>
</P
><P
> When prompted for a passphrase, leave it empty.
</P
><P
> Now, on the activehost, edit or create a file called
<TT
CLASS="FILENAME"
>~/.ssh/authorized_keys</TT
>. Initialize it with the content of
<TT
CLASS="FILENAME"
>~/.ssh/id_rsa_simplesnap.pub</TT
> from the backuphost. (Or, add to the
end, if you already have lines in the file.) Then, at the
beginning of that one very long line, add text like this:
</P
><PRE
CLASS="PROGRAMLISTING"
>command="/usr/sbin/simplesnapwrap",from="1.2.3.4",
no-port-forwarding,no-X11-forwarding,no-pty </PRE
><P
> (I broke that line into two for readability, but this must all
be on a single line in your file.)
</P
><P
> The <TT
CLASS="REPLACEABLE"
><I
>1.2.3.4</I
></TT
> is the IP address that
connections from the backuphost
will appear to come from. It may be omitted if the IP is not static,
but it affords a little extra security. The line will wind up looking
like:
</P
><PRE
CLASS="PROGRAMLISTING"
>command="/usr/sbin/simplesnapwrap",from="1.2.3.4",
no-port-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAA....</PRE
><P
> (Again, this should all be on one huge line.)
</P
><P
> If there are any ZFS datasets you do not want to be backed up, set
<CODE
CLASS="PARAMETER"
>org.complete.simplesnap:exclude</CODE
> property
on the activehost
to <CODE
CLASS="PARAMETER"
>on</CODE
>. For instance:
</P
><P
> <B
CLASS="COMMAND"
>zfs set org.complete.simplesnap:exclude=on
tank/junkdata</B
>
</P
><P
> Now, back on the backuphost, you should be able to run:
</P
><P
> <B
CLASS="COMMAND"
>ssh -i ~/.ssh/id_rsa_simplesnap activehost</B
>
</P
><P
> say yes when asked if you want to add the key to the known_hosts
file. At this point, you should see output containing:
</P
><P
> "simplesnapwrap: This program is to be run from ssh."
</P
><P
> If you see that, then simplesnapwrap was properly invoked
remotely.
</P
><P
> Now, create a ZFS filesystem to hold your backups. For
instance:
</P
><P
> <B
CLASS="COMMAND"
>zfs create tank/simplesnap</B
>
</P
><P
> I often recommend compression for <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> datasets, so:
</P
><P
> <B
CLASS="COMMAND"
>zfs set compression=lz4 tank/simplesnap</B
>
</P
><P
> (If that gives an error, use compression=on instead.)
</P
><P
> Now, you can run the backup:
</P
><P
> <B
CLASS="COMMAND"
>simplesnap --host activehost --setname mainset
--store tank/simplesnap
--sshcmd "ssh -i /root/.ssh/id_rsa_simplesnap"
</B
>
</P
><P
> You can monitor progress in <TT
CLASS="FILENAME"
>/var/log/syslog</TT
>. If all goes well, you
will see filesystems start to be populated under
<TT
CLASS="FILENAME"
>tank/simplesnap/host</TT
>.
</P
><P
> Simple!
</P
><P
> Now, go test that you have the data you expected to: look at
your <TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
> filesystems and make sure
they have everything expected. Test repeatedly over time that
you can restore as you expect from your backups.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN174"
></A
><H2
>Advanced: SETNAME usage</H2
><P
> Most people will always use the same <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>. The <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
> is used to
track and name the snapshots on the remote end. simplesnap tries to always
leave one snapshot on the remote, to serve as the base for a future
incremental.
</P
><P
> In some situations, you may have multiple bases for incrementals. The
two primary examples are two different backup servers backing up the
same machine, or having two sets of backup media and rotating them to
offsite storage. In these situations, you will have to keep different
snapshots on the activehost for the different backups, since they will
be current to different points in time.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN180"
></A
><H2
>Options</H2
><P
> All <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> options begin with two dashes (`--'). Most take
a parameter, which is to be separated from the option by a
space. The equals sign is not a valid separator for
<SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>.
</P
><P
> The normal <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> mode is backing up. An alternative
check mode is available, which requires fewer parameters. This
mode is described below.
</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><CODE
CLASS="OPTION"
>--backupdataset <TT
CLASS="REPLACEABLE"
><I
>DATASET</I
></TT
></CODE
></DT
><DD
><P
> Normally, <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> automatically obtains a list of
datasets to back up from the remote, and backs up all of
them except those that define the
<CODE
CLASS="PARAMETER"
>org.complete.simplesnap:exclude=on</CODE
>
property. With this option, <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> does not bother
to ask the remote for a list of datasets, and instead
backs up only the one precise
<TT
CLASS="REPLACEABLE"
><I
>DATASET</I
></TT
> given. For now, ignored when
<CODE
CLASS="OPTION"
>--check</CODE
> is given, but that may change in
the future. It would be best to not specify this option
with --check for now.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--check <TT
CLASS="REPLACEABLE"
><I
>TIMEFRAME</I
></TT
></CODE
></DT
><DD
><P
> Do not back up, but check existing backups. If any
datasets' newest backup is older than
<TT
CLASS="REPLACEABLE"
><I
>TIMEFRAME</I
></TT
>, print an error and
exit with a nonzero code. Scans all hosts unless a
specific host is given with <CODE
CLASS="OPTION"
>--host</CODE
>. The
parameter is in the format given to GNU <SPAN
CLASS="APPLICATION"
>date</SPAN
>(1); for
instance,
--check "30 days ago". Remember to enclose it in quotes
if it contains spaces.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--datasetdest
<TT
CLASS="REPLACEABLE"
><I
>DEST</I
></TT
></CODE
></DT
><DD
><P
> Valid only with <CODE
CLASS="OPTION"
>--backupdataset</CODE
>, gives a
specific destination for the backup, whith may be outside
the <TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
>. The <TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
>
must still exist, as it is used for storing lockfiles and
such.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--host</CODE
>
<TT
CLASS="REPLACEABLE"
><I
>HOST</I
></TT
></DT
><DD
><P
> Gives the name of the host to back up. This is both
passed to ssh and used to name the backup sets.
</P
><P
> In a few situations, one may not wish to use the same name
for both. It is recommend to use the Host and HostName
options in <TT
CLASS="FILENAME"
>~/.ssh/config</TT
> to configure aliases in this
situation.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--local</CODE
></DT
><DD
><P
> Specifies that the host being backed up is local to the
machine. Do not use ssh to contact it, and invoke the
wrapper directly. You would not need to
give <CODE
CLASS="OPTION"
>--sshcmd</CODE
> in this case. For
instance: <B
CLASS="COMMAND"
>simplesnap --local --store
/bakfs/simplesnap --host server1 --setname bak1</B
>
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--sshcmd
<TT
CLASS="REPLACEABLE"
><I
>COMMAND</I
></TT
></CODE
></DT
><DD
><P
> Gives the command to use to connect to the remote host.
Defaults to "ssh". It may be used to select an
alternative configuration file or keypair. Remember to
quote it per your shell if it contains spaces. For example:
--sshcmd "ssh -i /root/.id_rsa_simplesnap". This command
is ignored when <CODE
CLASS="OPTION"
>--local</CODE
> or
<CODE
CLASS="OPTION"
>--check</CODE
> is given.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--setname <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
></CODE
></DT
><DD
><P
> Gives the backup set name. Can just be a made-up word if
multiple sets are not needed; for instance, the hostname of
the backup server. This is used as part of the snapshot
name.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--store
<TT
CLASS="REPLACEABLE"
><I
>STORE</I
></TT
></CODE
></DT
><DD
><P
>Gives the ZFS dataset name where the data
will be stored. Should not begin with a slash. The
mountpoint will be obtained from the ZFS subsystem.
Always required.
</P
></DD
><DT
><CODE
CLASS="OPTION"
>--wrapcmd
<TT
CLASS="REPLACEABLE"
><I
>COMMAND</I
></TT
></CODE
></DT
><DD
><P
> Gives the path to simplesnapwrap (which must be on the
remote machine unless <CODE
CLASS="OPTION"
>--local</CODE
> is given).
Not usually relevant, since the
<CODE
CLASS="PARAMETER"
>command</CODE
> parameter in
<TT
CLASS="FILENAME"
>~root/.ssh/authorized_keys</TT
> gives the
path. Default: "simplesnapwrap"
</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN261"
></A
><H2
>Backup Interrogation</H2
><P
> Since <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> stores backups in standard ZFS datasets, you
can use standard ZFS tools to obtain information about backups.
Here are some examples.
</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN265"
></A
><H3
>Space used per host</H3
><P
> Try something like this:
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs list -r -d 1 tank/store
NAME USED AVAIL REFER MOUNTPOINT
tank/store 540G 867G 34K /tank/store
tank/store/host1 473G 867G 32K /tank/store/host1
tank/store/host2 54.9G 867G 32K /tank/store/host2
tank/store/host3 12.2G 867G 31K /tank/store/host3</PRE
><P
> Here, you can see that the total size of the <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> data
is 540G - the USED value from the top level. In this example,
host1 was using the most space -- 473G -- and host3 the least --
12.2G. There is 867G available on this zpool for backups.
</P
><P
> The <CODE
CLASS="PARAMETER"
>-r</CODE
> parameter to <B
CLASS="COMMAND"
>zfs
list</B
> requests a recursive report, but the
<CODE
CLASS="PARAMETER"
>-d 1</CODE
> parameter sets a maximum depth of 1
-- so you can see just the top-level hosts without all their
component datasets.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN275"
></A
><H3
>Space used by a host</H3
><P
> Let's say that you had the above example, and want to drill down
into more detail. Perhaps, for instance, we continue the above
example and drill down into host2:
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs list -r tank/store/host2
NAME USED AVAIL REFER MOUNTPOINT
tank/store/host2 54.9G 867G 32K /tank/...
tank/store/host2/tank 49.8G 867G 32K /tank/...
tank/store/host2/tank/home 7.39G 867G 6.93G /tank/...
tank/store/host2/tank/vm 42.4G 867G 30K /tank/...
tank/store/host2/tank/vm/vm1 32.0G 867G 29.7G -
tank/store/host2/tank/vm/vm2 10.4G 867G 10.4G -
tank/store/host2/rpool 5.12G 867G 32K /tank/...
tank/store/host2/rpool/misc 521M 867G 521M /tank/...
tank/store/host2/rpool/host2-1 4.61G 867G 33K /tank/...
tank/store/host2/rpool/host2-1/ROOT 317M 867G 312M /tank/...
tank/store/host2/rpool/host2-1/usr 3.76G 867G 3.76G /tank/...
tank/store/host2/rpool/host2-1/var 554M 867G 401M /tank/...</PRE
><P
> I've trimmed the "mountpoint" column here so it doesn't get
too wide for the screen.
</P
><P
> You see here the same 54.9G used as in the previous example,
but now you can trace it down. There were two zpools on
host2: tank and rpool. Most of the backup space -- 49.8G of
the 54.9G -- is used by tank, and only 5.12G by rpool. And in
tank, 42.4G is used by vm. Tracing it down, of that 42.4G
used by vm, 32G is in vm1 and 10.4G in vm2. Notice how the
values at each level of the tree include their descendents.
</P
><P
> So in this example, vm1 and vm2 are zvols corresponding to
virtual machines, and clearly take up a lot of space. Notice
how vm1 says it uses 32.0G but in the refer column, it only
refers to 29.7G? That means that the latest backup for vm2
used 29.7G, but when you add in the snapshots for that
dataset, the total space consumed is 32.0G.
</P
><P
> Let's look at an alternative view that will make the size
consumed by snapshots more clear:
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs list -o space -r tank/store/host2
NAME AVAIL USED USEDSNAP USEDDS USEDCHILD
.../host2 867G 54.9G 0 32K 54.9G
.../host2/tank 867G 49.8G 0 32K 49.8G
.../host2/tank/home 867G 7.39G 474M 6.93G 0
.../host2/tank/vm 867G 42.4G 50K 30K 42.4G
.../host2/tank/vm/vm1 867G 32.0G 2.35G 29.7G 0
.../host2/tank/vm/vm1 867G 10.4G 49K 10.4G 0
.../host2/rpool 867G 5.12G 0 32K 5.12G
.../host2/rpool/misc 867G 521M 51K 521M 0
.../host2/rpool/host2-1 867G 4.61G 51K 33K 4.61G
.../host2/rpool/host2-1/ROOT 867G 317M 5.44M 312M 0
.../host2/rpool/host2-1/usr 867G 3.76G 208K 3.76G 0
.../host2/rpool/host2-1/var 867G 554M 153M 401M 0</PRE
><P
> (Again, I've trimmed some irrelevant columns from this
output.)
</P
><P
> The AVAIL and USED columns are the same as before, but now you
have a breakdown of what makes up the USED column. USEDSNAP
is the space used by the snapshots of that particular
dataset. USEDDS is the space used by that dataset directly --
the same value as was in REFER before. And USEDCHILD is the
space used by descendents of that dataset.
</P
><P
> The USEDSNAP column is the
easiest way to see the impact your retention policies have on
your backup space consumption.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN287"
></A
><H3
>Viewing snapshots of a dataset</H3
><P
> Let's take one example from
before -- the 153M of snapshots in host2-1/var, and see what we
can find.
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs list -t snap -r tank/store/host2/rpool/host2-1/var
NAME USED AVAIL REFER
...
.../var@host2-hourly-2014-02-11_05.17.02--2d 76K - 402M
.../var@host2-hourly-2014-02-11_06.17.01--2d 77K - 402M
.../var@host2-hourly-2014-02-11_07.17.01--2d 18.8M - 402M
.../var@host2-daily-2014-02-11_07.17.25--1w 79K - 402M
.../var@host2-hourly-2014-02-11_08.17.01--2d 156K - 402M
.../var@host2-monthly-2014-02-11_09.01.36--1m 114K - 402M
...</PRE
><P
> In this output, the REFER column is the amount of data pointed
to by that snapshot -- that is, the size of /var at the moment
the snapshot is made. And the USED column is the amount of
space that would be freed if just that snapshot were deleted.
</P
><P
> Note this important point: it is normal for the sum of the
values in the USED column to be less than the space consumed
by the snapshots of the datasets as reported by USEDSNAP in
the previous example. The reason is that the USED column is
the data unique to that one snapshot. If, for instance, 100MB
of data existed on the system being backed up for
three hours yesterday, each snapshot could very well show less
than 100KB used, because that 100MB isn't unique to a
particular snapshot. Until, that is, two of the three
snapshots referncing the 100MB data are destroyed; then the
USED value of the last one referencing it will suddenly jump
to 100MB higher because now it references unique data.
</P
><P
> One other point -- an indication that the last backup was
successfully transmitted is the presence of a
__simplesnap_...__ snapshot at the end of the list. Do not
delete it.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN294"
></A
><H3
>Finding what changed over time</H3
><P
> The <B
CLASS="COMMAND"
>zfs diff</B
> command can let you see what
changed over time -- either across a single snapshot, or
across many. Let's take a look.
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs diff .../var@host2-hourly-2014-02-11_05.17.02--2d \
.../var@host2-hourly-2014-02-11_06.17.01--2d \
| sort -k2 | less
M /tank/store/host2/rpool/host2-1/var/log/Xorg.0.log
M /tank/store/host2/rpool/host2-1/var/log/auth.log
M /tank/store/host2/rpool/host2-1/var/log/daemon.log
...
M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.daily
M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.monthly
M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.weekly
M /tank/store/host2/rpool/host2-1/var/tmp</PRE
><P
> Here you can see why there was just a few KB of changes in
that snapshot: mostly just a little bit of logging was
happening on the system. Now let's inspect the larger
snapshot:
</P
><PRE
CLASS="PROGRAMLISTING"
># zfs diff .../var@host2-hourly-2014-02-11_07.17.01--2d \
.../var@host2-daily-2014-02-11_07.17.25--1w \
| sort -k2 | less
M /tank/store/host2/rpool/host2-1/var/backups
+ /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0
- /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0
+ /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz
R /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz
R /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.3.gz
...
M /tank/store/host2/rpool/host2-1/var/cache/apt
R /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin.KdsMLu -> /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin</PRE
><P
> Here you can see some file rotation going on, and a temporary
file being renamed to permanent. Normal daily activity on a
system, but now you know what was taking up space.
</P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN302"
></A
><H2
>Warnings, Cautions, and Good Practices</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN304"
></A
><H3
>Importance of Testing</H3
><P
> Any backup scheme should be tested carefully before being
relied upon to serve its intended purpose. This item is not
<SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>-specific, but pertains to every backup solution:
test that you are backing up the data you expect to before you
need it.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN308"
></A
><H3
>Use of zfs receive -F</H3
><P
> In order to account for various situations that could lead to
divergence of filesystems, including the simple act of mounting
them, <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> always uses <B
CLASS="COMMAND"
>zfs receive
-F</B
>. Any local changes you make to the <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>
store datasets will be lost at any time. If you need to make
local changes there, it is best to copy them elsewhere.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN314"
></A
><H3
>Extraneous Snapshot Buildup</H3
><P
> Since <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> sends all snapshots, it is possible that
locally-created snapshots made outside of your rotation scheme
will also be sent to your backuphost. These may not be
automatically reaped there, and may stick around. An example
at the end of the
<TT
CLASS="FILENAME"
>cron.daily.simplesnap.backuphost</TT
> file
included with <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> is one way to check for these.
They could automatically be reaped with <B
CLASS="COMMAND"
>zfs
destroy</B
> as well, but this must be carefully tuned to
local requirements, so an example of doign that is
intentionally not supplied with the distribution.
</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN321"
></A
><H3
>Internal simplesnap snapshots</H3
><P
> <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> creates snapshots beginning with __simplesnap_
followed by your <TT
CLASS="REPLACEABLE"
><I
>SETNAME</I
></TT
>. Do not
create, remove, or alter these snapshots in any way, either on
the activehost or the backuphost. Doing so may lead to
unpredictable side-effects.
</P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN326"
></A
><H2
>Bugs</H2
><P
> Ordinarily, an interrupted transfer is no problem for
<SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
>. However, the very first transfer of a dataset
poses a bit of a problem, since the <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> wrapper can't
detect failure in this one special case. If your first transfer
gets interrupted, simply zfs destroy the __simplesnap_...__
snapshot on the activehost and rerun. NEVER DESTROY
__simplesnap SNAPSHOTS IN ANY OTHER SITUATION!
</P
><P
> If, by way of the
<CODE
CLASS="PARAMETER"
>org.complete.simplesnap:exclude</CODE
>
property or the <CODE
CLASS="OPTION"
>--backupdataset</CODE
> or
<CODE
CLASS="OPTION"
>--datasetdest</CODE
> parameters, you do not request a
parent dataset to be backed up, but do request a descendent
dataset to be backed up, you may get an error on the first
backup
because the
dataset tree leading to the destination location for that
dataset has not yet been created. <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> performs only
the narrow actions you request. Running an appropriate
<B
CLASS="COMMAND"
>zfs create</B
> command will rectify the
situation.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN337"
></A
><H2
>See Also</H2
><P
>zfSnap (1), zfs (8).</P
><P
> The <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> homepage: <A
HREF="https://github.com/jgoerzen/simplesnap"
TARGET="_top"
>https://github.com/jgoerzen/simplesnap</A
>
</P
><P
> The examples included with the <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> distribution, or on
its homepage.
</P
><P
> The zfSnap package compliments <SPAN
CLASS="APPLICATION"
>simplesnap</SPAN
> perfectly. Find it
at
<A
HREF="https://github.com/graudeejs/zfSnap"
TARGET="_top"
>https://github.com/graudeejs/zfSnap</A
>.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN348"
></A
><H2
>AUTHOR</H2
><P
>This software and manual page was written by John Goerzen <CODE
CLASS="EMAIL"
><<A
HREF="mailto:jgoerzen@complete.org"
>jgoerzen@complete.org</A
>></CODE
>.
Permission is
granted to copy, distribute and/or modify this document under
the terms of the <ACRONYM
CLASS="ACRONYM"
>GNU</ACRONYM
> General Public License, Version 3 any
later version published by the Free Software Foundation. The
complete text of the GNU General Public License is included in
the file COPYING in the source distribution.
</P
></DIV
></BODY
></HTML
>
|