# TARing a full system



## bitsandnumbers (Sep 13, 2014)

Hi,

I'm gonna need a backup of one of my systems to RAID the disk with another one for automatic backup. For convenience, and by looking at my current setup, I'd like to create an archive of my entire system to uncompress it later when the RAID is setup. I know that doing so blindly will just put TAR in a loop when trying to process some folders. So I'd like your wise judgements on the best possible way(s) of doing so in a clean and efficient fashion. Basically, I want to compress my system in a single archive so that when everything is ready I can uncompress it from root and replace the clean new system with the old one.

If there are better ways of achieving this, I'm listening to all suggestions


----------



## wblock@ (Sep 13, 2014)

Backup Options For FreeBSD shows how to do that.

The Handbook section on setting up mirrors shows how to set them up with one new drive and one existing drive, too: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/geom-mirror.html.


----------



## bitsandnumbers (Sep 13, 2014)

Hi, thank you very much for your reply. I'm trying the "dump" command (`dump -C16 -b64 -0uanL -h0 -f /usr/backup/root.dump /`), but I systematically get an error:


```
DUMP: WARNING: Cannot use -L on an unmounted filesystem.
dump: /: unknown file system
```

I'm using a ZFS filesystem. Maybe it's the reason the dump fails ?


----------



## bsdkeith (Sep 13, 2014)

If you do use `tar`, you can use the `exclude` option to not include files or directories.


----------



## bitsandnumbers (Sep 13, 2014)

bsdkeith said:
			
		

> If you do use `tar`, you can use the `exclude` option to not include files or directories.


Yeah I know, but I never succeeded in using it. The quotes for the exclude parameters are different between systems for instance, and other subtleties I never quite mastered. If I'd use TAR, I'd try to find a how to somewhere, but didn't find one that work. I always end up in a loop :/


----------



## Beastie (Sep 13, 2014)

bitsandnumbers said:
			
		

> ```
> DUMP: WARNING: Cannot use -L on an unmounted filesystem.
> dump: /: unknown file system
> ```
> ...


As I don't use ZFS, I wouldn't know about this particular case. That being said, dump(8) supports using device-special files (e.g. /dev/ada0s1a).



			
				bitsandnumbers said:
			
		

> bsdkeith said:
> 
> 
> 
> ...


`tar --exclude='some directory' ...` does that. You may also be interested in the *--one-file-system* option.

~~~~



			
				bsdkeith said:
			
		

> If you do use `tar`, you can use the `exclude` option to not include files or directories.


dump(8) also supports exclusion through file flags: `chflags nodump /usr/src`.
Check dump(8)'s "honor level" *-h* option.


----------



## wblock@ (Sep 13, 2014)

bitsandnumbers said:
			
		

> I'm using a ZFS filesystem. Maybe it's the reason the dump fails ?



Yes.  dump() is for UFS filesystems.  The equivalent for ZFS are snapshots.  The brand-new ZFS chapter of the Handbook has more information: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/zfs.html.


----------

