# rsync all partition contents from one HDD to another



## ccc (Oct 20, 2012)

hi

I'd like to migrate FreeBSD from one HDD to another.
Which rsync parameter should I use for hard-links, file/directory permissions etc.?


----------



## jb_fvwm2 (Oct 20, 2012)

```
# from the source, below represented by the 'dot' ... the root of the copy
# and the destination mounted on /mnt
#dot# rsync -vaH --delete-delay --partial --stats --numeric-ids --inplace --archive --compress --hard-links --one-file-system --bwlimit=2000 . /mnt 
#tmp# rsync...        . /mnt/tmp             #etc, for other next filesystems
```
It's never failed here. The shell saves history across reboots so I've never had to type it all again except in unusual restore incidences.
I've only a general idea of why it works and am reluctant to ever change the path scheme outlined herein (unknown results sometimes occur.)
For some reason, I copy tmp, usr etc BEFORE /
In many cases, one can up the BWLIMIT to 6000 or so. (Sometimes not.)
...
Re the schg mentioned below, I usually run a script to clear them before the rsync, it does indeed cause trouble on the next incremental upgrade otherwise.


----------



## wblock@ (Oct 21, 2012)

ccc said:
			
		

> I'd like to migrate FreeBSD from one HDD to another.
> Which rsync parameter should I use for hard-links, file/directory permissions etc.?



If the original filesystems are UFS, use dump(8)/restore(8).  Seriously.  rsync, even with the file flags patch, has trouble writing files with the schg flag set.  There's a bug report with a patch I have not tested: https://bugzilla.samba.org/show_bug.cgi?id=8941

Otherwise, I use axHAX --delete --fileflags --force-change.


----------



## gordon@ (Oct 21, 2012)

+1 on dump(8)/restore(8). It will end up much better than using rsync.


----------



## wblock@ (Oct 21, 2012)

For completeness, Backup Options For FreeBSD shows how to copy filesystems with dump(8) and restore(8).

When migrating to a new disk, remember that the boot code also must be installed, or it won't boot.  An easy way to make sure everything is set up is to do a minimal install to the new disk, then restore over it.  That's also described in the document above.


----------



## gpw928 (Oct 22, 2012)

wblock@ said:
			
		

> Otherwise, I use axHAX --delete --fileflags --force-change.



Hi,

I use -axHAX --delete --sparse --numeric-ids.

--sparse means that holey files don't grow when copied.

--numeric-ids means I can bring the files back from another host with correct owner/group.

--fileflags --force-change are somewhat of a mystery to me.  They are not mentioned in my local (FreeBSD 8.1-RELEASE) rsync man pages, and not anywhere else I looked on the net.

Cheers,


----------



## wblock@ (Oct 22, 2012)

--fileflags is an added feature only available when net/rsync is built with the FLAGS option enabled.  It's added to the man page also.  --force-change may be part of that same option.


```
--fileflags             preserve file-flags (aka chflags)
...
--force-change          affect user/system immutable files/dirs
```


----------



## fluca1978 (Oct 22, 2012)

Assuming the disks are equal in size, and can be both online at the same time, also dd(1) is a solution.


----------

