The dump
command in Unix/Linux is used to backup and restore file systems. You can exclude certain directories or files from a dump using the exclude
option. Here’s how to do it:
dump -0u -f /path/to/backup-file /filesystem/to/backup -X /path/to/exclude-file
Here, the -X
option is used to specify a file that lists directories or files to exclude from the backup. The file should contain one exclude pattern per line, using the same syntax as the find
command. For example:
/home/user/logs
/home/user/tmp
*.log
*.tmp
This will exclude the logs
and tmp
directories in the user
home directory, as well as all files with the extensions .log
and .tmp
.
You can also use the exclude
option to exclude directories or files based on a pattern. For example, to exclude all directories named logs
and all files with the extension .log
, you can use:
dump -0u -f /path/to/backup-file /filesystem/to/backup -exclude '*logs' -exclude '*.log'
This will exclude any directory or file whose name ends with logs
or has the extension .log
.
Note that the exclude
option is case-sensitive, and patterns are matched against the full path of each file or directory.