Full tar backup for Linux excluding specific root folders

I have a question that I cannot find the answer to.

I am trying to write a shell script to perform a full system backup using tar. Obviously, there are several folders that I do not want to do for backup (/ dev, / mnt, / proc, / tmp, etc.). There are a large number of folders that I do not want to backup, so I use the "exclude-from" flag so that the command is relatively clean.

The problem is that it does not work.

Here are the tar flags that I use:

--create
--file $BACKUP_FILE
--preserve-permissions
--same-owner
--numeric-owner
--listed-incremental $INCREMENTAL_FILE
--level=0
--xz
--directory /
--exclude-caches
--exclude-from $EXCLUDE_FILE
-v

Here is my exception file:

/dev
/lost+found
/media
/mnt
/proc
/run
/sys
/tmp
/var/spool
/var/run
/var/tmp

script, - , . "-exclude" ( ). "-exclude-from $EXCLUDE_FILE" "-exclude-from = $EXCLUDE-FILE", , ( , ).

tar, , -, , . , , .

Googling , , , , , "/" . , , , . , , "media" , , /media, .

+4
2

, , 30 . , './' ( '/'), , . , root . /media ===/media.

. "/", "./", , . , exclude, , , , .

+2

ArchWiki , tar, , , rsync. ArchWiki , rsync. root, :

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /path/to/backup/folder

-aAX , " ". , , , , ACL .

, rsync , :

rsync -aAXv --exclude-from=FILE /* /path/to/backup/folder

-, /mnt /media, , . , - , , , , .

+4

Source: https://habr.com/ru/post/1570930/


All Articles