{"id":167128,"date":"2019-12-17T16:32:47","date_gmt":"2019-12-17T08:32:47","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=167128"},"modified":"2019-12-17T16:31:44","modified_gmt":"2019-12-17T08:31:44","slug":"backup-restore-repair","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/backup-restore-repair.html","title":{"rendered":"XFS\u6587\u4ef6\u7cfb\u7edf\u7684\u5907\u4efd\u3001\u6062\u590d\u3001\u4fee\u590d"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nXFS\u6587\u4ef6\u7cfb\u7edf\u662f\u7845\u8c37\u56fe\u5f62\u516c\u53f8(Silicon Graphics Inc,\u7b80\u79f0SGI)\u5f00\u53d1\u7684\u7528\u4e8eIRIX(\u4e00\u4e2aUNIX\u64cd\u4f5c\u7cfb\u7edf)\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c\u540e\u5c06XFS\u79fb\u690d\u5230Linux\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u3002XFS\u662f\u9ad8\u7ea7\u65e5\u5fd7\u6587\u4ef6\u7cfb\u7edf\uff0c\u5176\u7279\u70b9\u6781\u5177\u4f38\u7f29\u6027\uff0c\u540c\u65f6\u4e5f\u5f88\u5065\u58ee\u30022000\u5e745\u6708XFS\u901a\u8fc7GNU\u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\u79fb\u690d\u5230Linux\u7cfb\u7edf\u4e0a\uff0c\u901a\u8fc7\u5341\u591a\u5e74\u7684\u4e0d\u65ad\u4fee\u6539\u5df2\u7ecf\u6210\u4e3a\u4e00\u6b3e\u975e\u5e38\u6210\u719f\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u5728\u591a\u9879\u9488\u5bf9XFS\u7684\u6027\u80fd\u6d4b\u8bd5\u4e0a\uff0cXFS\u90fd\u53d6\u5f97\u4e86\u4e0d\u4fd7\u7684\u6210\u7ee9\uff0c\u9ad8\u5e76\u53d1\u73af\u5883\u4e0b\u751a\u81f3\u5df2\u7ecf\u8d85\u8fc7ext4\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001XFS\u6587\u4ef6\u7cfb\u7edf\u7684\u5907\u4efd\u4e0e\u6062\u590d<\/strong><\/div>\n

XFS\u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u6574\u4e2a\u5206\u533a\u5907\u4efd\u7684\u5de5\u5177xfsdump\u4f9b\u7528\u6237\u4f7f\u7528\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u4e0d\u501f\u52a9\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u7684\u60c5\u51b5\u4e0b\u5bf9XFS\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7684\u6570\u636e\u5b9e\u65bd\u5907\u4efd\u3002<\/p>\n

\u521b\u5efaXFS\u5206\u533a\u53ca\u6d4b\u8bd5\u6587\u4ef6<\/strong><\/span><\/div>\n
[root@localhost ~]# ls \/dev\/sd*\r\n\/dev\/sda  \/dev\/sda1  \/dev\/sda2  \/dev\/sdb\r\n[root@localhost ~]# fdisk \/dev\/sdb\r\nWelcome to fdisk (util-linux 2.23.2).\r\n\r\nChanges will remain in memory only, until you decide to write them.\r\nBe careful before using the write command.\r\n\r\n\r\nCommand (m for help): p\r\n\r\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x08a5199d\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\r\nCommand (m for help): n\r\nPartition type:\r\n   p   primary (0 primary, 0 extended, 4 free)\r\n   e   extended\r\nSelect (default p): p\r\nFirst sector (2048-41943039, default 2048): \r\nUsing default value 2048\r\nLast sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G\r\nPartition 1 of type Linux and of size 1 GiB is set\r\n\r\nCommand (m for help): p\r\n\r\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x08a5199d\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/sdb1            2048     2099199     1048576   83  Linux\r\n\r\nCommand (m for help): w\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\nSyncing disks.\r\n[root@localhost ~]# partprobe\r\nWarning: Unable to open \/dev\/sr0 read-write (Read-only file system).  \/dev\/sr0 has been opened read-only.\r\n[root@localhost ~]# ls \/dev\/sd*\r\n\/dev\/sda  \/dev\/sda1  \/dev\/sda2  \/dev\/sdb  \/dev\/sdb1\r\n[root@localhost ~]# mkfs.xfs -f \/dev\/sdb1\r\nmeta-data=\/dev\/sdb1              isize=512    agcount=4, agsize=65536 blks\r\n         =                       sectsz=512   attr=2, projid32bit=1\r\n         =                       crc=1        finobt=0, sparse=0\r\ndata     =                       bsize=4096   blocks=262144, imaxpct=25\r\n         =                       sunit=0      swidth=0 blks\r\nnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1\r\nlog      =internal log           bsize=4096   blocks=2560, version=2\r\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\r\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\r\n[root@localhost ~]# blkid \/dev\/sdb1      \r\n\/dev\/sdb1: UUID=\"61a5e59d-92d3-458d-ac09-7d945469cda6\" TYPE=\"xfs\" \r\n[root@localhost ~]# mkdir \/file\r\n[root@localhost ~]# echo \"\/dev\/sdb1 \/file xfs defaults 0 0\" >> \/etc\/fstab \r\n[root@localhost ~]# mount -a\r\n[root@localhost ~]# df -h\r\nFilesystem             Size  Used Avail Use% Mounted on\r\n\/dev\/mapper\/rhel-root   17G  1.9G   16G  12% \/\r\ndevtmpfs               901M     0  901M   0% \/dev\r\ntmpfs                  912M     0  912M   0% \/dev\/shm\r\ntmpfs                  912M  8.7M  903M   1% \/run\r\ntmpfs                  912M     0  912M   0% \/sys\/fs\/cgroup\r\n\/dev\/sr0               3.8G  3.8G     0 100% \/yum\r\n\/dev\/sda1             1014M  143M  872M  15% \/boot\r\ntmpfs                  183M     0  183M   0% \/run\/user\/0\r\n\/dev\/sdb1             1014M   33M  982M   4% \/file\r\n[root@localhost ~]# cd \/file\/\r\n[root@localhost file]# ls\r\n[root@localhost file]# touch file{1..100}\r\n[root@localhost file]# ls\r\nfile1    file16  file23  file30  file38  file45  file52  file6   file67  file74  file81  file89  file96\r\nfile10   file17  file24  file31  file39  file46  file53  file60  file68  file75  file82  file9   file97\r\nfile100  file18  file25  file32  file4   file47  file54  file61  file69  file76  file83  file90  file98\r\nfile11   file19  file26  file33  file40  file48  file55  file62  file7   file77  file84  file91  file99\r\nfile12   file2   file27  file34  file41  file49  file56  file63  file70  file78  file85  file92\r\nfile13   file20  file28  file35  file42  file5   file57  file64  file71  file79  file86  file93\r\nfile14   file21  file29  file36  file43  file50  file58  file65  file72  file8   file87  file94\r\nfile15   file22  file3   file37  file44  file51  file59  file66  file73  file80  file88  file95\r\n<\/pre>\n
\u5907\u4efdXFS\u5206\u533a<\/strong><\/span><\/div>\n
[root@localhost file]# mkdir \/backup  \r\n[root@localhost file]# yum install -y xfsdump\r\n[root@localhost file]# xfsdump -f \/backup\/file.bak \/file\r\n#\u5229\u7528xfsdump\u5907\u4efd\u6302\u8f7d\u70b9\/file\u5bf9\u5e94\u7684\u5206\u533a\r\nxfsdump: using file dump (drive_simple) strategy\r\nxfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control\r\n\r\n ============================= dump label dialog ==============================\r\n#\u8f93\u5165dump\u4f1a\u8bdd\u6807\u7b7e\r\nplease enter label for this dump session (timeout in 300 sec)\r\n -> file.bak\r\nsession label entered: \"file.bak\"\r\n\r\n --------------------------------- end dialog ---------------------------------\r\n\r\nxfsdump: level 0 dump of localhost.localdomain:\/file\r\nxfsdump: dump date: Thu Oct 31 22:16:02 2019\r\nxfsdump: session id: 02a1445f-5ff3-4518-ab2c-888d9e2a4c44\r\nxfsdump: session label: \"file.bak\"\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: 52800 bytes\r\n\r\n ============================= media label dialog =============================\r\n#\u8f93\u5165\u5a92\u4f53\u6807\u7b7e\r\nplease enter label for media in drive 0 (timeout in 300 sec)\r\n -> file\r\nmedia label entered: \"file\"\r\n\r\n --------------------------------- end dialog ---------------------------------\r\n\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 86544 bytes\r\nxfsdump: dump size (non-dir files) : 0 bytes\r\nxfsdump: dump complete: 27 seconds elapsed\r\nxfsdump: Dump Summary:\r\nxfsdump:   stream 0 \/backup\/file.bak OK (success)\r\nxfsdump: Dump Status: SUCCESS\r\n[root@localhost file]# ls \/backup\/\r\n#\u5df2\u7ecf\u6210\u529f\u521b\u5efa\u5907\u4efd\u6587\u4ef6\r\nfile.bak\r\n<\/pre>\n
\u6062\u590d\u8fc7\u7a0b<\/strong><\/span><\/div>\n
[root@localhost file]# ls\r\nfile1    file16  file23  file30  file38  file45  file52  file6   file67  file74  file81  file89  file96\r\nfile10   file17  file24  file31  file39  file46  file53  file60  file68  file75  file82  file9   file97\r\nfile100  file18  file25  file32  file4   file47  file54  file61  file69  file76  file83  file90  file98\r\nfile11   file19  file26  file33  file40  file48  file55  file62  file7   file77  file84  file91  file99\r\nfile12   file2   file27  file34  file41  file49  file56  file63  file70  file78  file85  file92\r\nfile13   file20  file28  file35  file42  file5   file57  file64  file71  file79  file86  file93\r\nfile14   file21  file29  file36  file43  file50  file58  file65  file72  file8   file87  file94\r\nfile15   file22  file3   file37  file44  file51  file59  file66  file73  file80  file88  file95\r\n[root@localhost file]# rm -rf *\r\n[root@localhost file]# ls\r\n[root@localhost file]# xfsrestore -f \/backup\/file.bak \/file\r\nxfsrestore: using file dump (drive_simple) strategy\r\nxfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control\r\nxfsrestore: searching media for dump\r\nxfsrestore: examining media file 0\r\nxfsrestore: dump description: \r\nxfsrestore: hostname: localhost.localdomain\r\nxfsrestore: mount point: \/file\r\nxfsrestore: volume: \/dev\/sdb1\r\nxfsrestore: session time: Thu Oct 31 22:16:02 2019\r\nxfsrestore: level: 0\r\nxfsrestore: session label: \"file.bak\"\r\nxfsrestore: media label: \"file\"\r\nxfsrestore: file system id: 61a5e59d-92d3-458d-ac09-7d945469cda6\r\nxfsrestore: session id: 02a1445f-5ff3-4518-ab2c-888d9e2a4c44\r\nxfsrestore: media id: 2d1d9f33-dff3-4cfa-a2f6-bf65bd8f242b\r\nxfsrestore: using online session inventory\r\nxfsrestore: searching media for directory dump\r\nxfsrestore: reading directories\r\nxfsrestore: 1 directories and 100 entries processed\r\nxfsrestore: directory post-processing\r\nxfsrestore: restoring non-directory files\r\nxfsrestore: restore complete: 0 seconds elapsed\r\nxfsrestore: Restore Summary:\r\nxfsrestore:   stream 0 \/backup\/file.bak OK (success)\r\nxfsrestore: Restore Status: SUCCESS\r\n[root@localhost file]# ls\r\n#\u5df2\u7ecf\u6210\u529f\u6062\u590d\u88ab\u5220\u9664\u7684\u6587\u4ef6\r\nfile1    file16  file23  file30  file38  file45  file52  file6   file67  file74  file81  file89  file96\r\nfile10   file17  file24  file31  file39  file46  file53  file60  file68  file75  file82  file9   file97\r\nfile100  file18  file25  file32  file4   file47  file54  file61  file69  file76  file83  file90  file98\r\nfile11   file19  file26  file33  file40  file48  file55  file62  file7   file77  file84  file91  file99\r\nfile12   file2   file27  file34  file41  file49  file56  file63  file70  file78  file85  file92\r\nfile13   file20  file28  file35  file42  file5   file57  file64  file71  file79  file86  file93\r\nfile14   file21  file29  file36  file43  file50  file58  file65  file72  file8   file87  file94\r\nfile15   file22  file3   file37  file44  file51  file59  file66  file73  file80  file88  file95\r\n<\/pre>\n
\u4e8c\u3001XFS\u6587\u4ef6\u7cfb\u7edf\u7684\u68c0\u67e5\u548c\u4fee\u590d<\/strong><\/div>\n
\u521b\u5efaXFS\u6d4b\u8bd5\u5206\u533a<\/strong><\/span><\/div>\n
[root@localhost file]# fdisk \/dev\/sdb\r\nWelcome to fdisk (util-linux 2.23.2).\r\n\r\nChanges will remain in memory only, until you decide to write them.\r\nBe careful before using the write command.\r\n\r\n\r\nCommand (m for help): p\r\n\r\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x08a5199d\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/sdb1            2048     2099199     1048576   83  Linux\r\n\r\nCommand (m for help): n\r\nPartition type:\r\n   p   primary (1 primary, 0 extended, 3 free)\r\n   e   extended\r\nSelect (default p): p\r\nPartition number (2-4, default 2): \r\nFirst sector (2099200-41943039, default 2099200): \r\nUsing default value 2099200\r\nLast sector, +sectors or +size{K,M,G} (2099200-41943039, default 41943039): +1G\r\nPartition 2 of type Linux and of size 1 GiB is set\r\n\r\nCommand (m for help): p\r\n\r\nDisk \/dev\/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x08a5199d\r\n\r\n   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/sdb1            2048     2099199     1048576   83  Linux\r\n\/dev\/sdb2         2099200     4196351     1048576   83  Linux\r\n\r\nCommand (m for help): w\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\n\r\nWARNING: Re-reading the partition table failed with error 16: Device or resource busy.\r\nThe kernel still uses the old table. The new table will be used at\r\nthe next reboot or after you run partprobe(8) or kpartx(8)\r\nSyncing disks.\r\n[root@localhost file]# partprobe\r\nWarning: Unable to open \/dev\/sr0 read-write (Read-only file system).  \/dev\/sr0 has been opened read-only.\r\n[root@localhost file]# ls \/dev\/sd*\r\n\/dev\/sda  \/dev\/sda1  \/dev\/sda2  \/dev\/sdb  \/dev\/sdb1  \/dev\/sdb2\r\n[root@localhost file]# mkfs.xfs \/dev\/sdb2\r\nmeta-data=\/dev\/sdb2              isize=512    agcount=4, agsize=65536 blks\r\n         =                       sectsz=512   attr=2, projid32bit=1\r\n         =                       crc=1        finobt=0, sparse=0\r\ndata     =                       bsize=4096   blocks=262144, imaxpct=25\r\n         =                       sunit=0      swidth=0 blks\r\nnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1\r\nlog      =internal log           bsize=4096   blocks=2560, version=2\r\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\r\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\r\n<\/pre>\n
\u68c0\u67e5XFS\u6587\u4ef6\u7cfb\u7edf\uff0c\u5982\u679c\u68c0\u67e5\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u95ee\u9898\u5c06\u4f1a\u5217\u51fa<\/strong><\/span><\/div>\n
[root@localhost file]# xfs_repair -n \/dev\/sdb2\r\nPhase 1 - find and verify superblock...\r\nPhase 2 - using internal log\r\n        - zero log...\r\n        - scan filesystem freespace and inode maps...\r\n        - found root inode chunk\r\nPhase 3 - for each AG...\r\n        - scan (but don't clear) agi unlinked lists...\r\n        - process known inodes and perform inode discovery...\r\n        - agno = 0\r\n        - agno = 1\r\n        - agno = 2\r\n        - agno = 3\r\n        - process newly discovered inodes...\r\nPhase 4 - check for duplicate blocks...\r\n        - setting up duplicate extent list...\r\n        - check for inodes claiming duplicate blocks...\r\n        - agno = 0\r\n        - agno = 1\r\n        - agno = 2\r\n        - agno = 3\r\nNo modify flag set, skipping phase 5\r\nPhase 6 - check inode connectivity...\r\n        - traversing filesystem ...\r\n        - traversal finished ...\r\n        - moving disconnected inodes to lost+found ...\r\nPhase 7 - verify link counts...\r\nNo modify flag set, skipping filesystem flush and exiting.\r\n<\/pre>\n
\u81ea\u52a8\u68c0\u67e5\u5e76\u4fee\u590dXFS\u6587\u4ef6\u7cfb\u7edf<\/strong><\/span><\/div>\n
[root@localhost file]# xfs_repair \/dev\/sdb2        \r\nPhase 1 - find and verify superblock...\r\nPhase 2 - using internal log\r\n        - zero log...\r\n        - scan filesystem freespace and inode maps...\r\n        - found root inode chunk\r\nPhase 3 - for each AG...\r\n        - scan and clear agi unlinked lists...\r\n        - process known inodes and perform inode discovery...\r\n        - agno = 0\r\n        - agno = 1\r\n        - agno = 2\r\n        - agno = 3\r\n        - process newly discovered inodes...\r\nPhase 4 - check for duplicate blocks...\r\n        - setting up duplicate extent list...\r\n        - check for inodes claiming duplicate blocks...\r\n        - agno = 0\r\n        - agno = 1\r\n        - agno = 2\r\n        - agno = 3\r\nPhase 5 - rebuild AG headers and trees...\r\n        - reset superblock...\r\nPhase 6 - check inode connectivity...\r\n        - resetting contents of realtime bitmap and summary inodes\r\n        - traversing filesystem ...\r\n        - traversal finished ...\r\n        - moving disconnected inodes to lost+found ...\r\nPhase 7 - verify and correct link counts...\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

XFS\u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u6574\u4e2a\u5206\u533a\u5907\u4efd\u7684\u5de5\u5177xfsdump\u4f9b\u7528\u6237\u4f7f\u7528\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u4e0d\u501f\u52a9\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u7684\u60c5\u51b5\u4e0b\u5bf9XFS\u6587\u4ef6 […]<\/p>\n","protected":false},"author":63,"featured_media":167129,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-167128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=167128"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167128\/revisions"}],"predecessor-version":[{"id":167186,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/167128\/revisions\/167186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/167129"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=167128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=167128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=167128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}