FreeBSD 101 : Backup and restore utilities.

Incremental backups:

In this backup mode, only the data that has changed or the newly added one (since the last backup) is backed up.

Full backup:

In this mode, all the data is backed up, the "old" and the "new" one:

The dump utility:

The "dump" utility lets us do a full or incremental backup.


It dumps the content of the "/dev/ad0p1" onto the "/home/backup" file.

Level (0 to 9) : "level 0" ( as in the above example ) means that the dump utility will do a full backup. 
It is the default used when no level is specified, all the other levels do incremental backups.

The different levels tell the "dump" utility to copy the changes since the last dump that have the same or lower levels as explained inn the example below.

Example : - Most used backup policy or level sequence -

We use dump utility with the above sequence:

N: level number.

According to the sequence above:

0 : full backup.
3 : backup new or modified files since level 0 and 3.
2 : backup new or modified files since level 0 and 2.
4 : backup new or modified files since level 0, 3 and 4.
5 : backup new or modified files since level 0, 3 and 5.

Explanation for level 7 (as an example):

1- We backup 0 because its lower than 7.
2- We backup 3 because its lower than 7.
3- We skip 2 because its lower than the previous level 3.
4- We skip 5 because is greater than ( in the following levels of the sequence) .
5- We backup 4 because its lower than to 7.
6- We backup 7 because its equal to 7.

The same for the other levels, we backup files that have a lower or an equivalent level.

-f file : the backup is written to a device file, it could be a partition on a drive for example.
-L : It tells the dump utility that the filesystem it is backing up is mounted in "read-write/busy".

Dump will make a snapshot of the filesystem in the "/root/.snap" directory and then it will "dump" it.

All that to make sure that no read-write will occur on the filesystem we want to back up during the "dump" operation.

-u: Update the dates of the backup in the "/etc/dumpdates" file.

Incremental backups (/etc/dumpdates file):

Incremental backups are created using the "/etc/dumpdates" file, it contains information about backups, like the date , the dump level,...

The "cat" utility displays the content of a file.

Saving the backups on remote servers:

Dump files can be moved to other backup servers using a combination of the "bzip2" compression utility, shh to connect to the remote server and the "dd" utility to make the copy.

The "dd" utility:

The "dd" copies data in blocks from a source to a destination.


Copies data from the partition "/dev/ada0p1" to the partition "/dev/ada0p1" in blocks of 512 ko.

"|": means that the output of the previous command will serve as input to the next command.
"\" : to split a long command into multiple lines.

The command in the example above will do a full backup from /dev/ada0p1 on the Backup-Server (/home/backup/backup1.dump) after compressing the dumped content using the bzip2 utility.

Restoring the backup:

We can restore a file from a backup we made using the dump utility. We use for that purpose the command "restore".

The restore utility extracts the backup file to the current directory. We can use the "pwd" command to make sure we are extracting our backup into the right directory.

The restore utility(Interactive mode):

We can browse through files and directories inside the dump file and pick the files or directories we want to restore.

Below are the commands for the interactive mode:

ls : shows the content of the current directory.
cd : to browse directories.
pwd : lets you know the current directory.
add: to pick a file we want to restore.
delete: to ignore a file we don't want to restore.
extract : extract the files.

Example (add, delete):

We can for example add a directory and delete the files that we don't need.

We get the below result:

Information about "dumped" files:

We can get information ( dump level, date of the dump,... ) about a "dumped" file "/home/backup" using the "what" command.


Leave as a comment: