LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   tar --exclude --exclude-from (https://www.linuxquestions.org/questions/linux-software-2/tar-exclude-exclude-from-371501/)

cefn 10-10-2005 08:31 AM

tar --exclude --exclude-from
 
I'm having real trouble getting tar to behave when writing backups of a filesystem into the same filesystem. I'm stuck with this disk layout unfortunately. I suspect I don't fully understand the interaction between the command line options ...

--listed-incremental
--exclude
--exclude-files

Want to do a recursive gzipped tar backup of the whole filesystem from / (root) upwards. Then I want to tar incremental changes. The aim is to take an occasional full backup, and then take regular small snapshots of changes and lift them over the network.

Using /tmp to store the files, and using options --exclude backup.tar.gz and --exclude-from excluded.filelist to make the backup ignore the file it is actually writing, as well as some other files I want it to ignore.

However, for some reason, it's ignoring my specification of excluded files, and going ahead and trying to back them up, also the incremental seems to ignore the record of files already backed up using --listed-incremental.

I have modded the files so they just try to back up the /tmp directory instead of the whole filesystem. Still the same problem. The three scripts I'm using are inlined below. dump-exclude is used in common between both scripts in order to generate the exclusion list.

The incremental dump is actually coming out bigger than the full dump, because the exclusion list is being ignored! Help!


>>>>>>
#dump-exclude

#!/bin/bash
#
/usr/bin/find /tmp/ -type f -name 'dump*' > /tmp/dump-exclude.filelist


>>>>>>
#dump-full

#!/bin/bash
# Generates exclusion list in /tmp/dump-exclude.filelist
/root/backup/dump-exclude
# Makes temporary backup of last list of tarred files
/bin/mv -f /tmp/dump-full.tarlist /tmp/dump-full.tarlist.old
# Temporary modification for testing
cd /tmp
# Make incremental backup
/bin/tar --create --one-file-system --exclude-from /tmp/dump-exclude.filelist --listed-incremental /tmp/dump-full.tarlist --label "Archive of entire filesystem" . | /bin/gzip -c > /tmp/dump-full.tar.gz

>>>>>>
#dump-inc
#!/bin/bash
# Update the list of files to exclude from backup
/root/backup/dump-exclude
# Create copy of information about
# previous full backup for the incremental
# tar operation to build upon
/bin/cp -f /tmp/dump-full.tarlist /tmp/dump-inc.tarlist
# Temporary modification for testing
cd /tmp
# Make an incremental backup based on the --listed-incremental format file
# saved from the last full backup
/bin/tar --create --one-file-system --exclude /tmp/dump-inc.tar.gz --exclude-from /tmp/dump-exclude.filelist --listed-incremental /tmp/dump-inc.tarlist --label "Incremental archive of /" . | /bin/gzip -c > /tmp/dump-inc.tar.gz

Tinkster 10-11-2005 05:14 PM

Hi, and welcome to LQ! :)

One piece of essential info missing:
/tmp/dump-exclude.filelist

And for readabilities sake, try something like this:
Code:

/bin/tar  --one-file-system --exclude /tmp/dump-inc.tar.gz -X /tmp/dump-exclude.filelist --listed-incremental /tmp/dump-inc.tarlist --label "Incremental archive of /" -czf /tmp/dump-inc.tar.gz

Cheers,
Tink

cefn 10-11-2005 07:16 PM

Extra info needed
 
Thanks for getting back to me, Tink. Sorry to leave out info which would be essential.

One of the reasons I changed the script to only back up the /tmp directory is so that in principle one could run the scripts directly on any system, and these generate the /tmp/dump-exclude.filelist, but here's an example of the file which is created, and then later referenced, within both scripts...

#dump-exclude.filelist
>>>>>>>>>>>>
/tmp/dump-exclude.filelist
/tmp/dump-full.tar.gz
/tmp/dump-full.tarlist.old
/tmp/dump-full.tarlist
/tmp/dump-inc.tarlist
/tmp/dump-inc.tar.gz

Tinkster 10-11-2005 07:22 PM

Cool - and now you're saying that those files are being included
in backups despite the fact that they're in the exclusion-list?


Cheers,
Tink

cefn 10-11-2005 07:31 PM

That's about the size of it

tar xzvf /tmp/dump-full.tar.gz
Archive of entire filesystem
Reading `Archive of entire filesystem'
./
./.ICE-unix/
./.X11-unix/
./.font-unix/
./.iroha_unix/
./orbit-cefn/
./orbit-marks/
./orbit-root/
./.X0-lock
./dump-exclude.filelist
./dump-full.tarlist
./sess_0433a8087c8935bff7e06ecf48d85226
./sess_06596e96a2c1447fca642023c9531fc4
./sess_1b49cfe7b841f7212cbf9f8c0781b744
./sess_38ba59388572a0e3a76bd25faecf4015
./sess_4474316b118964011d788d20ab6bcda4
./sess_643b4e669d61ff46c46ea7739bbf4205
./sess_6c3a8fdeae8f433716342830130cb831
./sess_876df273bdef367f5d7af49d7390817e
./sess_8bd32ce1d05f383064a2bb6c5fc745a0
./sess_af2eed5ba5638085fb817269c834170f
./sess_d15ec8724bf2706bfe88e1660cf301a6
./sess_f3da9831944add58725333c07465d957


tar xzvf /tmp/dump-inc.tar.gz
Incremental archive of /
Reading `Incremental archive of /'
./
./.ICE-unix/
./.X11-unix/
./.font-unix/
./.iroha_unix/
./orbit-cefn/
./orbit-marks/
./orbit-root/
./dump-exclude.filelist
./dump-full.tar.gz
./dump-full.tarlist
./dump-inc.tarlist


All times are GMT -5. The time now is 05:27 PM.