{"id":4,"date":"2010-01-20T20:20:33","date_gmt":"2010-01-20T19:20:33","guid":{"rendered":"http:\/\/www.schoen-bloed.at\/blog\/?p=4"},"modified":"2010-02-22T16:07:00","modified_gmt":"2010-02-22T15:07:00","slug":"wie-repliziere-ich-mit-xfsdumpxfsrestore","status":"publish","type":"post","link":"https:\/\/www.schoen-bloed.at\/blog\/2010\/01\/wie-repliziere-ich-mit-xfsdumpxfsrestore\/","title":{"rendered":"Wie repliziere ich mit xfsdump\/xfsrestore?"},"content":{"rendered":"<p>Diese Anleitung soll helfen die Tools xfsdump und xfsrestore im Netzwerk einzusetzen um eine Partition zu replizieren.<!--more--><\/p>\n<p>XFS ist ein Journaling File System welches mit 2 n\u00fctzlichen Tools ausgestattet ist. Dabei handelt es sich um xfsdump und xfsrestore<\/p>\n<ul>\n<li>xfsdump erstellt Snapshots einer XFS Partition zur Laufzeit<\/li>\n<li>xfsrestore wird zum Zur\u00fcckspielen des Snapshots verwendet<\/li>\n<\/ul>\n<p>Warum sollte man diese Backuptools verwenden um zwei Partitionen zu synchronisieren?<\/p>\n<ul>\n<li>Weil es simpel ist und man keine zus\u00e4tzlichen Programme braucht<\/li>\n<li>Weil es auf bestehenden Installationen mit XFS Partitionen keine Ausfallzeit verursacht<\/li>\n<li>Weil es eine stabile und \u00a0getestete L\u00f6sung ist<\/li>\n<li>Weil Echtzeit-Replikation zu aufwendig f\u00fcr eine schnelle L\u00f6sung ist<\/li>\n<\/ul>\n<p>Wann sollte ich diese Methode nicht einsetzen?<\/p>\n<ul>\n<li>Sobald oft gro\u00dfe Dateien ge\u00e4ndert werden, z.B. Datenbanken mit Dateien \u00fcber 2 GB<\/li>\n<li>uvm<\/li>\n<\/ul>\n<p>Welche Software brauche ich f\u00fcr diese L\u00f6sung?<\/p>\n<p>Meine Server laufen alle samt unter <a href=\"http:\/\/www.debian.org\" target=\"_blank\">Debian<\/a> mit mehr oder weniger standardisierten Paketen, \u00a0soweit es geht, aber in diesem Fall k\u00f6nnen alle Pakete mit Debian bzw. <a href=\"http:\/\/www.gnu.org\" target=\"_blank\">GNU\/Linux<\/a> Bordmitteln installiert werden. Zur Vorbereitung installieren wir folgende Programme:<\/p>\n<ul>\n<li><a href=\"http:\/\/oss.sgi.com\/projects\/xfs\/\" target=\"_blank\" class=\"broken_link\" rel=\"nofollow\">xfsdump<\/a><\/li>\n<li><a href=\"http:\/\/netcat.sourceforge.net\/\" target=\"_blank\" class=\"broken_link\" rel=\"nofollow\">netcat<\/a><\/li>\n<\/ul>\n<p>Debian: <\/p>\n<blockquote><p>apt-get install xfsdump netcat<\/p><\/blockquote>\n<p>Bei anderen Distributionen gibt es \u00e4hnliche M\u00f6glichkeiten, diese werden sich auf der Seite der Distributionen sicher finden lassen.<\/p>\n<p>Wir beginnen mit dem base dump, diesen nennen wir Sonntag und schaut so aus:<\/p>\n<blockquote><p>xfsdump -f \/xfs\/KW12\/0.dump -l 0 -p 5 -L KW12 -M Sonntag \/srv<\/p><\/blockquote>\n<p>Parameterliste:<\/p>\n<ul>\n<li>-f \/xfs\/KW12\/0.dump &#8211; Ist der Pfad zur Backup Datei<\/li>\n<li>-l 0 (Null) &#8211; Bedeutet das ein komplettes Abbild erstellt wird<\/li>\n<li>-p 5 &#8211; Zeigt alle 5 Sekunden den aktuellen Transferstatus an<\/li>\n<li>-L KW12 &#8211; Setzt das Label auf &#8222;KW12&#8220;<\/li>\n<li>-M Sonntag &#8211; Benennt das Medium (diesen Dump) als &#8222;Sonntag&#8220;<\/li>\n<li>\/srv &#8211; Pfad zu der Partition die gesichert werden soll<\/li>\n<\/ul>\n<pre lang=\"none\">xfsdump: using file dump (drive_simple) strategy\r\nxfsdump: version 2.2.48 (dump format 3.0) - Running single-threaded\r\nxfsdump: WARNING: most recent level 0 dump was interrupted, but not resuming that dump since resume (-R) option not specified\r\nxfsdump: level 0 dump of battlegate:\/srv\r\nxfsdump: dump date: Sat Feb 20 18:23:32 2010\r\nxfsdump: session id: c5c3a85b-9a81-45c2-a8d8-a42d1b4aa744\r\nxfsdump: session label: \"KW12\"\r\nxfsdump: ino map phase 1: constructing initial dump list\r\nxfsdump: ino map phase 2: skipping (no pruning necessary)\r\nxfsdump: ino map phase 3: skipping (only one dump stream)\r\nxfsdump: ino map construction complete\r\nxfsdump: estimated dump size: 11027072 bytes\r\nxfsdump: creating dump session media file 0 (media 0, file 0)\r\nxfsdump: dumping ino map\r\nxfsdump: dumping directories\r\nxfsdump: dumping non-directory files\r\nxfsdump: ending media file\r\nxfsdump: media file size 11030816 bytes\r\nxfsdump: dump size (non-dir files) : 11009488 bytes\r\nxfsdump: dump complete: 0 seconds elapsed\r\nxfsdump: Dump Status: SUCCESS<\/pre>\n<p>F\u00fcr den zweiten Tag (Montag) verwenden wir folgende Parameter:<\/p>\n<blockquote><p>xfsdump -f \/xfs\/KW12\/1.dump -l 1 -p 5 -L KW12 -M Montag \/srv<\/p><\/blockquote>\n<p>Parameterliste (ge\u00e4nderte):<\/p>\n<ul>\n<li>-f \/xfs\/KW12\/1.dump &#8211; Die Datei f\u00fcr diesen Tag hei\u00dft 1.dump<\/li>\n<li>-l 1 &#8211; Das erste Level des Backups im Verh\u00e4ltnis zu 0.dump (Man k\u00f6nnte es auch gleich setzen mit dem ersten Inkrementellen Sicherungspfad)<\/li>\n<li>-M Montag &#8211; Dieses Medium hei\u00dft Montag<\/li>\n<\/ul>\n<pre lang=\"none\">xfsdump: using file dump (drive_simple) strategy\r\nxfsdump: version 2.2.48 (dump format 3.0) - Running single-threaded\r\nxfsdump: WARNING: most recent level 1 dump was interrupted, but not resuming that dump since resume (-R) option not specified\r\nxfsdump: level 1 incremental dump of battlegate:\/srv based on level 0 dump begun Sat Feb 20 18:23:32 2010\r\nxfsdump: dump date: Sat Feb 20 18:42:31 2010\r\nxfsdump: session id: 955863dc-0319-4925-905c-106e5729f160\r\nxfsdump: session label: \"KW12\"\r\nxfsdump: ino map phase 1: constructing initial dump list\r\nxfsdump: ino map phase 2: skipping (no pruning necessary)\r\nxfsdump: ino map phase 3: skipping (only one dump stream)\r\nxfsdump: ino map construction complete\r\nxfsdump: estimated dump size: 23122560 bytes\r\nxfsdump: creating dump session media file 0 (media 0, file 0)\r\nxfsdump: dumping ino map\r\nxfsdump: dumping directories\r\nxfsdump: dumping non-directory files\r\nxfsdump: ending media file\r\nxfsdump: media file size 23130400 bytes\r\nxfsdump: dump size (non-dir files) : 23108752 bytes\r\nxfsdump: dump complete: 1 seconds elapsed\r\nxfsdump: Dump Status: SUCCESS<\/pre>\n<p>Um diese Dumps auf einem neuen XFS Filesystem wiederherzustellen, m\u00fcssen diese in der gleichen Reihenfolge wie sie erstellt worden sind eingespielt werden.<\/p>\n<blockquote><p>xfsrestore -p 5 -r -f \/xfs\/KW12\/0.dump \/srvrepl\/<\/p><\/blockquote>\n<ul>\n<li>-p 5 &#8211; Zeigt alle 5 Sekunden den aktuellen Transferstatus an<\/li>\n<li>-r &#8211; Setzt xfsrestore davon in Kenntnis das es mehrere Dumps gibt die eingespielt werden<\/li>\n<li>-f \/xfs\/KW12\/0.dump &#8211; Die Datei f\u00fcr diesen Tag hei\u00dft 0.dump<\/li>\n<\/ul>\n<pre lang=\"none\">xfsrestore: using file dump (drive_simple) strategy\r\nxfsrestore: version 2.2.48 (dump format 3.0) - Running single-threaded\r\nxfsrestore: searching media for dump\r\nxfsrestore: examining media file 0\r\nxfsrestore: dump description:\r\nxfsrestore: hostname: battlegate\r\nxfsrestore: mount point: \/srv\r\nxfsrestore: volume: \/dev\/hdd1\r\nxfsrestore: session time: Sat Feb 20 18:23:32 2010\r\nxfsrestore: level: 0\r\nxfsrestore: session label: \"KW12\"\r\nxfsrestore: media label: \"Sonntag\"\r\nxfsrestore: file system id: 35bd167c-84a6-47d8-9128-a2027e845a64\r\nxfsrestore: session id: c5c3a85b-9a81-45c2-a8d8-a42d1b4aa744\r\nxfsrestore: media id: bbb03c73-aca1-4172-970d-53d470de50ac\r\nxfsrestore: using online session inventory\r\nxfsrestore: searching media for directory dump\r\nxfsrestore: reading directories\r\nxfsrestore: 1 directories and 1 entries processed\r\nxfsrestore: directory post-processing\r\nxfsrestore: restoring non-directory files\r\nxfsrestore: restore complete: 0 seconds elapsed\r\nxfsrestore: Restore Status: SUCCESS<\/pre>\n<blockquote><p>xfsrestore -p 5 -r -f \/xfs\/KW12\/1.dump \/srvrepl\/<\/p><\/blockquote>\n<ul>\n<li>-f \/xfs\/KW12\/1.dump &#8211; Die Datei f\u00fcr diesen Tag hei\u00dft 1.dump<\/li>\n<\/ul>\n<pre lang=\"none\">xfsrestore: using file dump (drive_simple) strategy\r\nxfsrestore: version 2.2.48 (dump format 3.0) - Running single-threaded\r\nxfsrestore: searching media for dump\r\nxfsrestore: examining media file 0\r\nxfsrestore: dump description:\r\nxfsrestore: hostname: battlegate\r\nxfsrestore: mount point: \/srv\r\nxfsrestore: volume: \/dev\/hdd1\r\nxfsrestore: session time: Sat Feb 20 18:42:31 2010\r\nxfsrestore: level: 1\r\nxfsrestore: session label: \"KW12\"\r\nxfsrestore: media label: \"Montag\"\r\nxfsrestore: file system id: 35bd167c-84a6-47d8-9128-a2027e845a64\r\nxfsrestore: session id: 955863dc-0319-4925-905c-106e5729f160\r\nxfsrestore: media id: 7fbedf79-4a55-4270-8ba9-08ee4da163a4\r\nxfsrestore: using online session inventory\r\nxfsrestore: searching media for directory dump\r\nxfsrestore: reading directories\r\nxfsrestore: 1 directories and 2 entries processed\r\nxfsrestore: directory post-processing\r\nxfsrestore: restoring non-directory files\r\nxfsrestore: restore complete: 0 seconds elapsed\r\nxfsrestore: Restore Status: SUCCESS<\/pre>\n<p>Nachdem alle Dumps eingespielt wurden, m\u00fcssen noch 1 bzw. 2 Verzeichnisse gel\u00f6scht werden.<\/p>\n<blockquote><p>rm -R \/srvrepl\/xfsrestorehousekeepingdir<br \/>\nrm -R \/srvrepl\/orphanage<\/p><\/blockquote>\n<p>Und wenn wir die Dumps direkt auf einem anderen Rechner replizieren wollen, k\u00f6nnen wir ganz simpel netcat dazu verwenden.<br \/>\nAuf Empf\u00e4ngerseite:<\/p>\n<blockquote><p>nc -l -p 2222 | xfsrestore -p 5 -r \/srvbackup<\/p><\/blockquote>\n<p>Netcat<\/p>\n<ul>\n<li>-l &#8211; versetzt Netcat in den Servermodus<\/li>\n<li>-p 2222 &#8211; ist der Port auf dem Netcat zuh\u00f6ren soll<\/li>\n<\/ul>\n<p>xfsrestore<\/p>\n<ul>\n<li>-p 5 &#8211; Zeigt alle 5 Sekunden den aktuellen Transferstatus an<\/li>\n<li>-r &#8211; Setzt xfsrestore davon in Kenntnis das es mehrere Dumps gibt die eingespielt werden<\/li>\n<\/ul>\n<p>Auf Senderseite:<\/p>\n<blockquote><p>xfsdump -l 0 -p 5 -L KW12 &#8211; \/srv | nc  2222 -q 5<\/p><\/blockquote>\n<blockquote><p>xfsdump -l 1 -p 5 -L KW12 &#8211; \/srv | nc  2222 -q 5<\/p><\/blockquote>\n<p>xfsdump Parameter:<\/p>\n<ul>\n<li>-f &#8211; Diese Option ist weggefallen und wurde durch einen Bindestrich vor dem xfs Pfad ersetzt<\/li>\n<li>-l 0\/1 &#8211; Hier wird das 0 Dump und der 1 Dump in zwei getrennten Aufrufen gesendet<\/li>\n<li>-M &#8211; Ist nicht notwendig da es direkt eingespielt wird.<\/li>\n<\/ul>\n<p>Netcat Parameter:<\/p>\n<ul>\n<li> 2222 &#8211; Die IP des Zielrechners und der Port dazu. (Der gleiche wie beim Empf\u00e4nger netcat angegeben)<\/li>\n<li>-q 5 &#8211; Beendet netcat nach einem EOF und 5 Sekunden Wartezeit<\/li>\n<\/ul>\n<p>In diesem Fall l\u00f6schen wir die zwei Verzeichnisse nicht, da diese vielleicht von xfsrestore in zuk\u00fcnftigen Aufrufen gebraucht werden.<\/p>\n<p>Ich hoffe dieser Artikel ist hilfreich, bei Anregungen, Fehlern oder \u00e4hnlichem, einfach einen Kommentar hinterlassen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eine Anleitung wie man die Tools xfsdump und xfsrestore im Netzwerk einsetzt um eine Partition zu replizieren.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[27,7,8,6],"_links":{"self":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/4"}],"collection":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":17,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":10,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/4\/revisions\/10"}],"wp:attachment":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}