Using DUMP to backup a drive

I installed FreeBSD 10.0 and I tried to plug in a backup HD with usb (ad0).

Worked:
Code:
#gpart destroy F ad0
#dd if=/dev/zero of=/dev/da0 count=2
#fdisk -BI /dev/da0
#bsdlabel -B -w da0s1
#newfs -U /dev/da0s1a


Problem:

I used
Code:
#dump -0 -f - /dev/ada0p2 | restore -r -f -

to dump because the one below does not work (complaint was: Tape is not a dump tape!).

Code:
#dump -0Lauf - /dev/ada0p2 | restore -rf –

So a dump was made fine but any files changed in the process are probably lost (this is fine, as long as the system files are intact).

The cloned HD won't boot (mountroot > came up), but I used ufs://dev/ada0s1a to get it boot.

The fstab had:

Code:
# Device Mountpoint FStype Options Dump Pass#
/dev/ada0p2 / ufs rw 1 1
/dev/ada0p3 none swap sw 0 0

Which does not match
Code:
# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ada0s1a 946084800 98675140 771722876 11% /
devfs 1 1 0 100% /dev

so I made changes to the file /etc/fstab to look like:

Code:
# Device Mountpoint FStype Options Dump Pass#
/dev/ada0s1a / ufs rw 1 1
/dev/ada0p3 none swap sw 0 0

The computer now boots fine but complains swap partition is not that there.
But I do not know what to put for the SWAP here.
 
Is it safe to do this in a running system?

Code:
# dd if=/dev/zero of=/usr/swap0 bs=1024k count=64

I probably should named it properly the first time, instead of
Code:
newfs -U /dev/da0s1a

I should have done
Code:
newfs -U /dev/ada0p2
newfs -U /dev/ada0p3

Then I probably won't have the error.
 
Yes, the error I got the first time might be due to fdiskand not gpart to do the job.
Thanks.
Here is what I did last night:

Code:
157  14:19   gpart create -s GPT da0
158  14:19   gpart add -t freebsd-boot -l gpboot -b 40 -s 512K da0
159  14:19   gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0
160  14:20   gpart add -t freebsd-swap -l gpswap -s 4096M da0
162  14:21   gpart add -t freebsd-ufs -l gpusrfs da0
164  14:23   newfs -U /dev/gpt/gpusrfs
170  14:23   mount /dev/gpt/gpusrfs /mnt
171  14:24   cd /mnt
172  14:25   dump -0Lauf - /dev/ada0s1a  | restore -rf –

I booted it today and swap works after creating the correct /etc/fstab file.

Code:
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/gpswap         none            swap    sw              0       0
/dev/gpt/gpusrfs        /               ufs     rw              1       1

I still do not understand why in the above codse, the boot sector was labeled as gpboot, but later referred to as gptboot. I tried to use my own name (with the two matching) and it did not work.
 
In the example shown in your post, -l gpboot gives the partition a label of gpboot. In the next line, bootcode from the file /boot/gptboot is written to the disk. That example has problems, like not mounting the new partition before restoring.
 
I am trying to dump directly to /mnt without cd to it first. However, it seems to dump the contents to / instead..so I got nothing in /mnt.
I am not sure why?
The reason I wanted to do this is I can start dump in office and can umount /mnt at home. if I cd to it, it won't umount.. Not a big deal but strange it wont work.

Code:
# dump -0Lauf - /dev/gpt/gpusrfs | restore -rf - /mnt
  DUMP: Date of this level 0 dump: Sat May  3 17:31:34 2014
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping snapshot of /dev/gpt/gpusrfs (/) to standard output
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 22608021 tape blocks.
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
 
dump(8) does not write the files. restore(8) does that, and, as far as I know, it only writes to the current directory. There are ways to get it to release the lock on that directory after it has finished. One way is to use a sub-shell, as shown in the Backup article above:
dump -C16 -b64 -0uanL -h0 -f - /usr | (cd /mnt && restore -ruf -)

Or it could be set to close after the process is complete (untested):
dump -C16 -b64 -0uanL -h0 -f - /usr | restore -ruf - ; exit
 
wblock,

Thank you for all the explanation!

I used my script to successfully duplicate 1TB to another 1TB, then 1TB to a 20G IDE. However the same code from 20G to a 250G (both IDE, connected via external USB), upon booting the 250G, it says "GPT Boot backup code bad" or something like that. What causes this problem? Gpart showsays there is a booting section with correct size.

Also, is there a way to configure the new drive simply with /dev/ufs, instead of/dev/gpt/ufs? I am not sure how to code it differently.
 
Thanks...still related to dump using the same script I got from the site recommended by wblock.

I tried to dump to several IDE drives (old but they were working on Freebsd 7.2 when pulled off). but it always quits in the middle (50-94% of dump), reboots, and then the main drive would have to be fscked because not dismounted properly. No error log in /var/log/messages.

Code:
# dump -0Lauf - /dev/ada0s1a | restore -rf -
  DUMP: Date of this level 0 dump: Wed May  7 10:46:48 2014
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping snapshot of /dev/ada0s1a (/) to standard output
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 15884592 tape blocks.
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
warning: ./.snap: File exists
./usr/local/etc/webmin/package-updates/current.cache: (inode 106261712) not found on tape
./usr/local/etc/webmin/system-status/history/maxes: (inode 106261719) not found on tape
./usr/local/etc/webmin/system-status/info: (inode 106261718) not found on tape
expected next file 13, got 12
  DUMP: 34.75% done, finished in 0:09 at Wed May  7 11:01:42 2014
  DUMP: 75.68% done, finished in 0:03 at Wed May  7 11:00:31 2014
expected next file 106261717, got 106261714
expected next file 106261717, got 106261715
expected next file 106261717, got 106261716

After this the computer rebooted. I have tried more than 6 times now. It does this to my externally connected IDE (vis USB), and also to internally connected IDE. I did have one success yesterday to a 60GB IDE which boots fine.

Drive info below (ada0= booting system drive, da0= IDE connected internally).

Code:
ada0 at ahcich2 bus 0 scbus2 target 0 lun 0
ada0: <ST31000520AS CC32> ATA-8 SATA 2.x device
ada0: Serial Number 9VX10E33
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad8
da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
da0: <ST325082 4A 3.AA> Fixed Direct Access SCSI-0 device
da0: 40.000MB/s transfers
da0: 238475MB (488397168 512 byte sectors: 255H 63S/T 30401C)
da0: quirks=0x2<NO_6_BYTE>
 
I guess there must be something wrong with that external drive. Today I was simply using cp to copy files to it and it hang my server....To the dumpster it will go!
 
It's not uncommon for USB drives to be unreliable. I've not had too much trouble with them, but it could just be that I don't use them much. Some might be more reliable than others, also.
 
I am now suspecting that computer has hardware problems. Because I tried 3 other IDEs internally and all caused hang. Now I am trying a different machine and see how it goes.

On the old machine, it stopped seeing my drive and refused to gpart destroy. But on the other machine now it is dumping. Except with a MBR drive, it wont do live system dump.

Here are the errors:
Code:
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:6:0:-1: Attached to scbus6
da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
da0: <ST325082 4A 3.AA> Fixed Direct Access SCSI-0 device
da0: 40.000MB/s transfers
da0: 238475MB (488397168 512 byte sectors: 255H 63S/T 30401C)
da0: quirks=0x2<NO_6_BYTE>
WARNING: /mnt was not properly dismounted
WARNING: /mnt was not properly dismounted
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 79 a0 68 00 00 80 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 79 a0 68 00 00 80 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 79 a0 68 00 00 80 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 79 a0 68 00 00 80 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 79 a0 68 00 00 80 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Error 5, Retries exhausted
(da0:umass-sim0:0:0:0): got CAM status 0x44
(da0:umass-sim0:0:0:0): fatal error, failed to attach to device
da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
da0: <ST325082 4A 3.AA> detached
(da0:umass-sim0:0:0:0): Periph destroyed
root@queen:/usr/backup/michbees #
 
Back
Top