# Backup entire system using dump



## SuperMiguel (Jun 19, 2009)

Im reading few things a about dump and i have few unclear points..

if i want to backup my entire system i tough i had to use: 

dump -0 -f /mnt/externaldrive/backuplfs.dump /

This ony copies my partition: ad4s1a

then i typed:

dump -0 -f /mnt/externaldrive/backuplfs.dump /usr

which copied the partition: ad4s1f


so my question is:

since i ran the command 2 times using the same file: backuplfs.dump will this file include partitions: ad4s1a and ad4s1f?? or only the last one??

Also is there a way to backup my full file system??? with out listing the folders individually ?? like i want to back up ad4s1a (/),ad4s1d (/var),ad4s1e(/tmp) and ad4s1f(/usr)  if not the command to backup everything would be:

dump -0 -f /mnt/externaldrive/backuplfs.dump / /var /tmp /usr

And if i run that command, when i run it again will it try to backup using incremental backups or it will copy everything again?
Thanks


----------



## jb_fvwm2 (Jun 20, 2009)

I've no time to re-read you post, but it might be easier
to find an fstab on the web which is simlar to yours and
include then the dump command (in the
web search)  (or vice versa).  Someone
may have written a guide you can use that would be more
reliable and already have a restore write-up in it; the
restore is probably more critical than the backup.

Unless there is a guide here already in the HowTo section.


----------



## graudeejs (Jun 20, 2009)

you need to dump each partition to separate file.

http://forums.freebsd.org/showthread.php?t=185



```
#!/bin/sh


[color="Red"]DEFAULT_BAK_FS='root var home usr'[/color]


if [ "$USER" = 'root' ]; then
	if [ -c /dev/ufs/backup ]; then

		if [ "$1" = '--backup' ]; then
			echo '*** starting backup ***'
			echo

			mkdir "/tmp/$(basename $0).$$"

			echo '*** saving kernel configuration ***'
			cat /usr/src/sys/i386/conf/killabsd | bzip2 > "/tmp/$(basename $0).$$/killabsd.bz2"

			if [ "$2" = 'all' ]; then
				for i in $DEFAULT_BAK_FS; do
					echo "*** dumping $i ***"
					dump -h 0 -0Laf - "/dev/ufs/$i" | gzip > "/tmp/$(basename $0).$$/$i.dump.gz"
					shift
				done
			else
				while [ $2 ]; do
					echo "*** dumping $2 ***"
					dump -h 0 -0Laf - "/dev/ufs/$2" | gzip > "/tmp/$(basename $0).$$/$2.dump.gz"
					shift
				done
			fi

			bakDate="$(date '+%Y-%m-%d')"

			echo '*** Mounting ks86backup ***'
			mount -o noatime /dev/ufs/backup /mnt

			echo '*** Saving Backups ***'
			if [ ! -d '/mnt/bak' ]; then mkdir '/mnt/bak'; fi
		
			if [ ! -d "/mnt/bak/$bakDate" ]; then rm -Rf "/mnt/bak/$bakDate"; fi
			mkdir "/mnt/bak/$bakDate"
		
			cp "/tmp/$(basename $0).$$/"* "/mnt/bak/$bakDate/"

			umount /mnt
			echo '*** ks86backup unmounted ***'

			echo '*** cleaning tmp ***'
			rm -Rf "/tmp/$(basename $0).$$"
			echo "*** backup $bakDate compleate ***"
			exit 0
		elif [ "$1" = '--restore' ]; then
			echo 'not implemented yet'
			exit 1
		else
			echo 'Err: unknown command'
			exit 1
		fi
	else
		echo "Err: backup drive ain't plugged"
		exit 1
	fi
else
	echo "Err: you're not root"
	exit 1
fi

echo "Err: you shouldn't naturally see this. A bug is somwhere."
exit 1
```

here's my backup script.
I used this to dump important to me FS to /tmp/backup... and then to copy to my 16GB flash
It depends on UFS labels

to use this script make sure you have ufs labels in /dev/ufs/
and edit the red line


----------



## vivek (Jun 20, 2009)

Your are overwriting file. Use -L option to dump live file system

day0 (full backup (Sunday)):

```
dump -0uLf /mnt/externaldrive/week0/fsroot0.dump /
```

day1 (level 1 (Monday)):

```
dump -1uLf /mnt/externaldrive/week0/fsroot1.dump /
```

day2 (level 2, Tue):

```
dump -1uLf /mnt/externaldrive/week0/fsroot2.dump /
```
....
day6 (level 6 Sat):

```
dump -6uLf /mnt/externaldrive/week0/fsroot6.dump /
```

Now start same process with week1. If possible backup should be taken in single user mode (though -L option make it live backup easy). Tower of Hanoi sequence is known for the dump level scheduling. This is what we use in production. dump level

```
0 3 2 5 4 7 6 9 8
```
To do full full-restoration, you should skip these ineffective archives i.e. your sequence should be as

```
0 2 4 6 8
```
Read dump and restore man page.


----------



## graudeejs (Jun 20, 2009)

I'd suggest to use fs name in dump file name.
That way if you change setup it's much easier to restore from dumps


----------



## SuperMiguel (Jun 22, 2009)

and using dump is a better solution than using rsync.. correct?


----------



## graudeejs (Jun 22, 2009)

I've never tried rsync


----------



## CyberCr33p (Jun 29, 2009)

The only problem with this method is doing mysql backups (not recommended).


----------



## graudeejs (Jun 29, 2009)

Well, you can create ufs snapshot, and then dump it 
I believe it solves the problem


----------



## vivek (Jun 29, 2009)

UFS snapshot makes *SQL online backup pretty easy without putting any load on server.


----------



## Davers (Aug 12, 2012)

This is giving me a head ache.
I need another beer...


----------

