LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-07-2012, 03:59 PM   #1
dilettante9
Member
 
Registered: Jun 2012
Location: U.S.
Distribution: Debian, Xubuntu
Posts: 46

Rep: Reputation: Disabled
Excluding trash in tar backup


I am using Debian, and I'm backing up my entire file structure to one tar file. I would like to exclude files that I have already deleted and are in the trash. However, this is proving difficult, since the trash files appear to be spread out all over the file system.

More specifically, the command I am using is:

tar zcvpf <target file> --one-file-system --exclude=home/patrick/MyBackups --exclude=mnt --exclude=proc --exclude=sys --exclude=dev/pts --exclude=root/.local/share/Trash / 2> <log file>

This, of course, excludes the folder with root trash, but there are plenty of other folders that appear to contain trash, which I learned when I went to root and entered the command "find -iname "*trash*" and got something like 100 folders with the name "trash" in them. In particular, I know that there are separate trash folders for each user (which, in my case, is only one user, myself, other than root).

For obvious reasons, I don't want to waste disk space backing up trash, which recently I noticed was adding an extra 5 GB to the backup file size and swelling it from 1.5 GB to 6.5 GB (since I had recently deleted some large files).

Therefore, I'm wondering if anyone knows of a way to exclude all the trash folders with a single option in the tar command? (Of course, I don't want to be over-inclusive in my exclusions, as maybe there's a legitmate, non-deleted folder that has the word "trash" in its name).

Any ideas?

Last edited by dilettante9; 07-07-2012 at 04:00 PM.
 
Old 07-08-2012, 07:38 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
The only *trash* you need to exclude are the root and user .local/share/Trash.
 
Old 07-08-2012, 02:29 PM   #3
dilettante9
Member
 
Registered: Jun 2012
Location: U.S.
Distribution: Debian, Xubuntu
Posts: 46

Original Poster
Rep: Reputation: Disabled
Thanks, bigrigdriver, it's helpful to know that those are the only two active Trash folders.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] tar excluding some files infraquest Linux - Newbie 7 06-11-2010 06:35 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
Excluding directories from tar? LocoMojo Linux - Software 6 01-24-2006 01:01 AM
tar, excluding directories recursively towlie Linux - Newbie 3 06-17-2004 12:32 PM
tar and excluding files murshed Linux - Newbie 7 03-15-2003 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration