# gmirror as a backup tool? {it works fine!]



## beesatmsu (Aug 29, 2010)

I wanted to rotate a couple of disks and mirror it maybe once a month, as a backup tool. 

what is the proper procedure for using gmirror as a backup?

today I tried two things: 

1). shutdown one system without using [CMD=""]gmirror remove gm0 ad6[/CMD] first, and used the mirror to boot in another machine...it got hanged during the boot up in 2 different machines (at dev moused).  I did a fsck, and then it rebooted fine...

2). I did  [CMD=""]gmirror remove gm0 ad6[/CMD] first, then shutdown...but for the "slave" I got the message:


```
Mounting root from ufs:/dev/gm8s1a
setrootbyname failed
ffs_mountroot: can't find rootvp
Root mount failed: 6

Manual root filesystem specification:
<fstype>:<device> Mount <device> using filesystem <fstype>
e.g. ufs:da0s1a
? List valid disk boot devices
<empty line> Abort manual input
```

trying 
	
	



```
ufs:/dev/ad6s1
```
 did get into the command prompt, but rebooting it will come to the same point...

in both cases, the original disk can boot ok.

so is #1 the right procedure? maybe it was just a fluke that I got a disk error? 

what causes the 2nd error? it does not make sense freebsd wont find the booting device since the mirror should have created the same fstab file under /etc, the same as the "master" disk?


Thanks.  Zach


----------



## beesatmsu (Aug 29, 2010)

Not long ago I remember I thought maybe the fstab file was to blame,

since it specifies gm0s1X:


```
# Device        Mountpoint      FStype  Options         Dumirrorp       Pass#
/dev/mirror/gm0s1b      none            swap    sw              0       0
/dev/mirror/gm0s1a      /               ufs     rw              1       1
/dev/mirror/gm0s1e      /tmp            ufs     rw              2       2
/dev/mirror/gm0s1f      /usr            ufs     rw              2       2
/dev/mirror/gm0s1d      /var            ufs     rw              2       2
/dev/mirror/acd0        /cdrom          cd9660  ro,noauto       0       0
```

I wrote a script to copy an alternative fstab file into /etc/fstab (e.g. changing it to gm6s1X, for ad6), 
wait for mirror to be clean, then removed one drive, and copied the above one back...

it did not seem to help either...


----------



## da1 (Aug 30, 2010)

I wouldn't recommend gmirror for a backup but I see what your aiming at.

Here is what I would do (seems dirty but I know it works)
build a mirror, power down the pc and just remove 1 drive. The hdd that remains in the pc will continue to function and same with the other one (that you removed).

If you do gmirror remove keep in mint that remove does the following:

```
Remove the given component(s) from the mirror and clear meta-data on it.
```

Now a question from my side: Does removing the meta-data prevent the disk from booting up ? Is it ONLY removing the gmirror meta-data and leaving everything else intact ? Someone more experienced on this topic could clear this up.

Nevertheless, keep in mind that a mirror with 1 disk only, does not save you from hardware malfunctions.


----------



## mix_room (Aug 30, 2010)

mirroring isn't a form of backup. Only of increased uptime. Repeat 10 times: RAID is _NOT_ a backup solution. 

I would suggest deciding on what needs backing up and how. 
Entire system, perhaps dump: http://forums.freebsd.org/showthread.php?t=4901
only data, perhaps rsync or rsnapshot. 

Getting a cheap USB-enclosure will enable you to connect the disk when needed. You can then dump/rsync/rsnapshot the data to it as needed.


----------



## beesatmsu (Aug 30, 2010)

I think it worked once for me...I took a drive and went home and it booted right up...one small possibility: I was mirroring 750 gig to a 1000 gig drive, and using the 1000 gig to reboot, this last time. I mirrored one 750 gig yesterday...no time to do more testing though. 

gmirror seems to be a nice way of backing up stuff...I do use rsync in a crontab to backup html and mysql files daily to another server.   but gmirror, if it works right, seems to be more hassle free? 

what is the point of gmirroring, if one disk does not boot ok? both should have identical content and able to boot normally? 

Da1: I think one needs to use forget command, or freebsd freaks out and panic (cannot save data to a non-existing device). this happened to me yesterday...after forget command, it seems to be ok.


----------



## da1 (Aug 30, 2010)

not quite.

if you remove a disk, the OS thinks it just went haywire (it should not panic at all). it has no way of knowing you removed it (it can be a hdd wire meltdown for that matter ...). the forget command simply tells gmirror to:


> Forget about components which are not connected.  This command is useful when a disk has failed and cannot be reconnected, preventing the remove command from being used to remove it



so normally, you use it after 1 hdd goes to hell (or when the devil (a.k.a. user) pulls it out himself ).

this "backup solution" is not a backup solution in the first place. regardless of what is it and what it isn't, for me, for instance, is impossible to do what you do. therefore, I cannot consider it a backup solution.

but, then again, different ppl have different ways of doing things (nothing wrong in that)


----------



## beesatmsu (Aug 30, 2010)

In some ways, I am trying to simulate one HD going bad...so the other one is expected to be up and running in no time..otherwise, what is the point of gmirroring? 

no? if I cannot access the data on the mirror...I am doing the gmirroring for nothing then...


----------



## kpa (Aug 30, 2010)

You should be able to boot from the mirror with one drive missing, if not there's something wrong with your set up.


----------



## beesatmsu (Aug 30, 2010)

it is possible that I did not "remove/forget" when exchanging the drives...but gmirror did not complain and went ahead and build the mirror each time I swapped drives (the 2nd one is always recognized as ad8, first one ad6, both sata drives). I did it by the book (changed loader.conf, fstab, etc).


----------



## beesatmsu (Aug 31, 2010)

tried again this morning..yanked out one drive after flags are "clean"...booted both machines up...and both works fine...

so gmirror would work fine for duplicating a disk or as infrequent backup...


----------



## beesatmsu (Dec 8, 2010)

Ok, I have successfully used gmirror to mirror 4 drives and all booting fine. so now my backup and 2ndary DNS/Web server is a perfect copy of the main one...and I stash 2 others somewhere else. 

I did not encounter the error again (one that asks you to specify a booting drive)..not sure why. 

I wait until the flags are clean and 100% synchronized. then reboot, take the slave out, which can boot as a master in a different machine. all my MB has the same ethernet card, it seems...so I just need to write a scrip to change the etc/conf, hosts, httpd.conf and named.conf files. 

I tried mirroring a 750g (Segate) to 1000G (Hitachi) and it also works fine -- A bit strange...must have the same cylinders or something...

so now all my machines are working fine with apache, php, mysql, kde...except I found Konqueror crashes....which is minor because firefox works fine.


----------



## beesatmsu (Jan 17, 2012)

so rebooting without "gmirror forget gm0 adx" (where x=drive number), works fine..

but if you issue gmirror forget before shutting down. the copy wont work but the master will.  strange.


----------

