Dump-backup

This script do backups using dump, compresses it with bzip2 and use gpg to encrypt the backup. It can also send logs to your email. As you should know dump works only with ext2/ext3 filesystems, sorry no reiserfs, xfs user could give a look for xfsdump.

Dump
For ext2/ext3 filesystems only, see Dump & restore to install instructions and references.

GPG
High recommendable!! Installation instruction here: GPG.

Mail server
Installation instruction here: Postfix.

Install
Copy the script to /root/ or any place that only root can read, don't forget the permission of execution: chmod 700 dump-bakup.sh. The file could be downloaded here.

If you want to encrypt the backup create a file with the password on a place where only the root can read, like /root/passwordfile, and write on the script: GPG_PASSFILE="/root/passwordfile"

Automation
You can use it to backup to an local attached hd, in this case you have just to configure cron. Or if you want to back it up to a remote machine go to remote backup.

Configure cron
For more informations about Cron.

The follow lines configure the cron to make a level 0 backup of home at 0:10 of friday and level 1 every day at 1:15.

Remote backup
See Remote backup with dump and ssh.

Excluding files not to be backuped
Depending on your partitioning, some backup target filesystems may include files which you don't want to backup. If you do wish to exclude them, you can mark their i-nodes with "no dump flag" with specific utilities. You may want to set this attribute for files updated frequently but no need to backup, such as proxy cache directory.

This can be done with lsattr(1) and chattr(1). Lsattr shows you the flag status of the file, and chattr sets it. For example,

The files or directories with no dump flag (+d) are excluded from the target of dump. In the above example, the directory used by Squid cache system and its huge contents are marked so that they will not be dumped. Once the directory is marked with this flag, the files that will be created inside it will also have the same attribute.

Note that this specification is ignored by default on level 0 full dump, and works only at the incremental backups of level 1 and later. If you want this to work on level 0, you should specify h option on the dump command line.