Gentoo Archives: gentoo-server

From: "Jesse
To: gentoo-server@l.g.o
Subject: RE: [gentoo-server] Quick restores
Date: Thu, 01 Dec 2005 16:23:50
Message-Id: FB5D3CCFCECC2948B5DCF4CABDBE6697545C2A@QTEX1.qg.com
1 Excellent! Just the thing I need to shore up my backups at home.
2 However, here at work I think it'd need a little sprucing up for the
3 software RAID sets.
4
5 Thanks!
6 Rich
7
8 -----Original Message-----
9 From: Michael Irey [mailto:michael@××××.org]
10 Sent: Wednesday, November 30, 2005 7:59 PM
11 To: gentoo-server@l.g.o
12 Subject: Re: [gentoo-server] Quick restores
13
14
15 On Wednesday 30 November 2005 1:59 pm, A. Khattri wrote:
16 >
17 > Im wondering if anyone has written a script (or maybe there's a tool
18 to do
19 > this) that will make binary packages of everything installed on a
20 server
21 > which can then be used to perform very quick restores in the event of
22 a
23 > major failure?
24 >
25
26 I use the following to do a quick and complete restore for a remote
27 gentoo
28 server at 1and1.
29
30
31 ----------------------------------------
32 | Linux Backup and Bare Metal Recovery |
33 ----------------------------------------
34
35 -- Backup
36
37 1) save metadata about how the disk is partitioned.
38
39 # sfdisk -l > /etc/partition.bak
40 # cp /etc/fstab /etc/fstab.bak
41
42
43 2) back up master boot record (MBR)
44
45 # dd if=/dev/hda of=/etc/mbr.bak bs=512 count=1
46
47
48 3) back up the operating system:
49
50 # mount /boot ## if its not already
51 # cd /
52 # tar -jcf --anchored --exclude '/sys' --anchored --exclude '/proc'
53 --anchored --exclude '/lost+found' - / | ssh target "cat >
54 filename.tar.bz2"
55
56 TODO: ssh -> ftp for 1and1
57
58
59 -- Restore
60
61 1) boot rescue mode ( debian 2.6 at 1and1 )
62
63
64 2) partition drive(s)
65
66 # ssh backupserver 'cat /etc/partition.bak'
67 Disk /dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
68 Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting
69 from 0
70
71 Device Boot Start End #cyls #blocks Id System
72 /dev/sda1 * 0+ 8 9- 72261 83 Linux
73 /dev/sda2 9 133 125 1004062+ 82 Linux swap /
74 Solaris
75 /dev/sda3 134 9728 9595 77071837+ 83 Linux
76 /dev/sda4 0 - 0 0 0 Empty
77
78
79 # sfdisk /dev/sda << EOF
80 0,9,83,*
81 9,125,82
82 134,9595,83
83 ,,0;
84 EOF
85 notes:
86 sfdisk reads lines of the form <start> <size> <id> <bootable>
87 <c,h,s> <c,h,s>
88 where each line fills one partition descriptor.
89
90
91 3) create file systems
92
93 # mke2fs /dev/sda1
94 # mke2fs -j /dev/sda3
95 # mkswap /dev/sda2
96
97 # mkdir /mnt/gentoo
98 # mkdir /mnt/gentoo/boot
99
100 # swapon /dev/sda2
101 # mount -t ext3 /dev/sda3 /mnt/gentoo
102 # mount /dev/sda1 /mnt/gentoo/boot
103
104 4) restore OS and data
105
106 # cd /mnt/gentoo
107 # ssh target "cat filename.tar.bz2" | tar jpvxf -
108 notes:
109 -j Decompress with bzip2
110 -p Preserve permissions
111 -v Verbose
112 -x Extract
113 -f File
114
115 TODO: ssh -> ftp for 1and1
116
117 5) restore MBR
118
119 # dd if=/mnt/gentoo/etc/mbr.bak of=/dev/sda bs=512 count=1
120 notes:
121 one could run grub-install --no-floppy /dev/sda instead.
122
123
124 --end
125
126
127 --
128 Michael Irey
129 System Administrator
130
131 ......................................................................
132 SightWorks, Inc.
133 5331 SW Macadam Avenue, Suite 348
134 Portland, Oregon 97239
135
136 Web: http://www.sightworks.com
137
138 SightWorks : Creative Internet Technologies
139 --
140 gentoo-server@g.o mailing list
141
142 --
143 gentoo-server@g.o mailing list