LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2012, 01:13 AM   #1
rationalthinker1
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
TAR Exclude everything in folder except this folder


Hello, I want to create a backup of my Home folder. Here's what I've done.

Code:
GZIP=-9
time=`date "+%y.%m.%d.%H.%M.%S"`
tar cvzf "/home/raza/Ubuntu One/$time.backup.tar.gz" \
--exclude="*.tmp" \
--exclude-caches-all \
--exclude="/home/raza/backup.sh" \
--exclude="/home/raza/*[Cc]ache*" \
--exclude="/home/raza/*[Tt]humbnails*" \
--exclude="/home/raza/*[Ii]cons?*" \
--exclude="/home/raza/*[Ll]ogs?*" \
--exclude="/home/raza/.opera/vps" \
--exclude="/home/raza/.opera/temporary_downloads" \
--exclude="/home/raza/Downloads" \
--exclude="/home/raza/Ubuntu One" \
--exclude="/home/raza/.local/share/Trash" \
"/home/raza/" > fileSaved.txt
There's a folder called /home/raza/.config/sublime-text-2/ that I want to exclude EXCEPT this this directory /home/raza/.config/sublime-text-2/Packages/User.

How do I do that?

Thank You.
 
Old 04-30-2012, 01:39 AM   #2
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Hi
how about adding these files after the first tar:
Code:
# to be included
tar avzf "/home/raza/Ubuntu One/$time.backup.tar.gz" \
 /home/raza/.config/sublime-text-2/Packages/User \
>> fileSaved.txt
 
1 members found this post helpful.
Old 04-30-2012, 02:28 AM   #3
rationalthinker1
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
I tried that too, it didn't work. It gave me no errors, just didn't archive it.

Edit:

Ohhhh, I get it, I'll try that.

Last edited by rationalthinker1; 04-30-2012 at 02:29 AM.
 
Old 04-30-2012, 08:26 AM   #4
rationalthinker1
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
I tried:
Quote:
tar avzf "/home/raza/Ubuntu One/$time.backup.tar.gz" \
/home/raza/.config/sublime-text-2/Packages/User \
>> fileSaved.txt
tar: You must specify one of the `-Acdtrux' or `--test-label' options
Try `tar --help' or `tar --usage' for more information.

Quote:
tar rvzf "/home/raza/Ubuntu One/$time.backup.tar.gz" \
/home/raza/.config/sublime-text-2/Packages/User \
>> fileSaved.txt
tar: Cannot update compressed archives
Try `tar --help' or `tar --usage' for more information.


Again, thank you.
 
Old 04-30-2012, 08:46 AM   #5
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
you are actually trying to updating a compressed archive that will not work for adding files later on. first you need to create uncompressed tar package and than Add file with "r" than compress it. using gzip




First Part
Quote:
GZIP=-9
time=`date "+%y.%m.%d.%H.%M.%S"`
tar cvf "/home/raza/Ubuntu One/$time.backup.tar" \
--exclude="*.tmp" \
--exclude-caches-all \
--exclude="/home/raza/backup.sh" \
--exclude="/home/raza/*[Cc]ache*" \
--exclude="/home/raza/*[Tt]humbnails*" \
--exclude="/home/raza/*[Ii]cons?*" \
--exclude="/home/raza/*[Ll]ogs?*" \
--exclude="/home/raza/.opera/vps" \
--exclude="/home/raza/.opera/temporary_downloads" \
--exclude="/home/raza/Downloads" \
--exclude="/home/raza/Ubuntu One" \
--exclude="/home/raza/.local/share/Trash" \
"/home/raza/" > fileSaved.txt
Second Part

Quote:
tar rvf "/home/raza/Ubuntu One/$time.backup.tar" \
/home/raza/.config/sublime-text-2/Packages/User \
>> fileSaved.txt

third part
Quote:
gzip -9 /home/raza/Ubuntu One/$time.backup.tar
I am Pretty much sure that it will work perfectly.

Thanks,
em31amit
Amit M.
 
2 members found this post helpful.
Old 04-30-2012, 08:20 PM   #6
rationalthinker1
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yes, that works perfectly.

Thank you.


For reference:

Code:
 GZIP=-9
 time=`date "+%y.%m.%d.%H.%M.%S"`
 tar cvpf "/home/raza/Ubuntu One/$time.backup.tar" \
 --exclude="*.tmp" \
 --exclude-caches-all \
 --exclude="/home/raza/*[Cc]ache*" \
 --exclude="/home/raza/*[Tt]humbnails*" \
 --exclude="/home/raza/*[Ii]cons?*" \
 --exclude="/home/raza/*[Ll]ogs?*" \
 --exclude="/home/raza/.opera/vps" \
 --exclude="/home/raza/.opera/temporary_downloads" \
 --exclude="/home/raza/Downloads" \
 --exclude="/home/raza/Ubuntu One" \
 --exclude="/home/raza/.local/share/Trash" \
 --exclude="/home/raza/.config/sublime-text-2" \
 --exclude="/home/raza/.thunderbird/*/ImapMail" \
 "/home/raza/" > fileSaved.txt

 tar rvpf "/home/raza/Ubuntu One/$time.backup.tar" \
 "/home/raza/.config/sublime-text-2/Packages/User" \
 >> fileSaved.txt

 gzip -9 "/home/raza/Ubuntu One/$time.backup.tar"

Last edited by rationalthinker1; 04-30-2012 at 08:22 PM.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exclude a folder from a recursive delete? raz230 Linux - General 6 12-23-2011 01:57 PM
how do i tar a folder to another location? steve51184 Linux - Software 4 12-11-2009 12:36 PM
want to 'tar' a folder without some contents of folder shipon_97 Linux - Newbie 5 10-13-2007 04:21 AM
TAR: Unpack file, exclude a folder Smeerbalg Linux - Software 1 01-29-2006 07:59 AM
tar.gz a folder tubby Linux - General 1 08-12-2002 05:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 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