LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-03-2010, 06:40 PM   #1
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Rep: Reputation: 101Reputation: 101
Question Need help with a tar command


Ubuntu 10.04

As part of my nightly backup script I archive my home directory with the following command
Quote:
tar -cvpzf /quitelarge/_mirror/mirror1/home-ken.gz /home/ken 2>> /quitelarge/_mirror/tar-error.log
It seems to work fine and I have recovered files from the archive on occasion. Actually I keep 7 rolling daily backups and a monthly burn to DVD. That said, yesterday I had an issue...

I had an sftp connection made by Nautilus to my server. Ubuntu for whatever reason places an icon on the desktop showing the connection. When I ran the script it decided to archive everything on my server - all 1.4 TB. I caught the problem when home-ken.gz was about 5 GB. I stopped the process, closed the sftp connection, rolled back the backups and tried again. This time I got a file of the expected size - about 45 MB.

In the error log I did find that the tar process was trying to suck the entire contents of the server into the archive file
Quote:
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/asound/ICH5/pcm0c/sub0: file changed as we read it
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/asound/ICH5/pcm0c: file changed as we read it
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/asound/ICH5: file changed as we read it
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/asound: file changed as we read it
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/scsi: file changed as we read it
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/acpi/event: Cannot open: Permission denied
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/acpi/fadt: Cannot open: Permission denied
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/acpi/dsdt: Cannot open: Permission denied
tar: /home/ken/.gvfs/sftp for ken on taylor10/proc/irq/21/smp_affinity: Cannot open: Permission denied
So the question is... is there an option I can place on the tar command to tell it NOT to follow the ssh connection which is sitting on my desktop? The closest thing I see in the documentation is -h which tells tar to "follow symlinks; archive and dump the files they point to." I am NOT specifying -h so if the ssh connection is treated as a symlink by tar I would still not expect the remote contents to be tarred.

TIA,

Ken
 
Old 09-03-2010, 08:20 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
See 'man tar', the "--exclude" and "--exclude-from" switches?
 
Old 09-03-2010, 09:31 PM   #3
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
OK -exclude but what to exclude? The properties for the icon on the desktop are as follows
Quote:
Name: sftp for ken on taylor10
Type: folder(inode/directory
Contents: 20 items, totalling 2.9 MB
Location: on the desktop
Volume: sftp for ken on taylor10
If I click on the icon I see the contents of my home folder on taylor10, the server, (7 folders and one link to folder) or if I show hidden file there are of course a lot of them. So I have no idea what the 20 items refers to.

Further confusing me is the fact that if I issue ls -a when my terminal pwd is the Desktop I see nothing as far as the sftp icon.

What pattern do I try to exclude???

Ken
 
Old 09-04-2010, 06:23 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Try something like '--exclude /home/ken/.gvfs/sftp\ for\ ken\ on\ taylor10/'?
 
Old 09-04-2010, 07:14 AM   #5
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
I use tar like this

say I was backing up my system.
Code:
tar -cvpzf /path/to/backup.tgz --exclude=/dev --exclude=/mnt --exclude=/media --exclude=/sys --exclude=/proc --exclude=lost+found /
Just replace /path/to/backup.tgz, any --exclude=yourFiles, and / with your info.

Just to add you may want to do your script like this.
Code:
tar -cvpzf /quitelarge/_mirror/mirror1/home-ken.tgz --exclude=/home/ken/.gvfs/sftp\ for\ ken\ on\ taylor10/proc /home/ken
Somebody feel free to correct me if Im wrong but I think that will resolve your issue

Last edited by jmc1987; 09-04-2010 at 07:20 AM.
 
Old 09-04-2010, 07:54 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by taylorkh View Post
OK -exclude but what to exclude? The properties for the icon on the desktop are as follows
If I click on the icon I see the contents of my home folder on taylor10, the server, (7 folders and one link to folder) or if I show hidden file there are of course a lot of them. So I have no idea what the 20 items refers to.

Further confusing me is the fact that if I issue ls -a when my terminal pwd is the Desktop I see nothing as far as the sftp icon.
It's a Desktop File. It contains the name of what it refers to and it's treated specially by GUI file managers, but not the command line. Post the output of ls in the desktop directory when the icon is showing.
 
Old 09-04-2010, 09:05 AM   #7
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
Thanks folks! I think I am on the track of a solution. There is nothing on my Desktop related to this issue
Quote:
ken@taylor12:~/Desktop$ ls -la
total 15928
drwxr-xr-x 2 ken ken 4096 2010-09-04 08:47 .
drwxr-xr-x 60 ken ken 4096 2010-09-04 08:49 ..
-rw-r--r-- 1 ken ken 2185470 2010-07-13 16:39 catalogCMP2010.pdf
-rw-r--r-- 1 ken ken 2713874 2006-02-06 17:39 Guidelines to GTAW.pdf
-rw-r--r-- 1 ken ken 99 2010-08-21 08:35 Matt
-rw-r--r-- 1 ken ken 11369609 2006-08-11 11:36 TIG Handbook.pdf
ken@taylor12:~/Desktop$
However, if I backup to /home/ken I find a hidden folder .gvfs whih contains
Quote:
ken@taylor12:~/.gvfs$ ls -la
total 8
dr-x------ 3 ken ken 0 2010-09-03 12:32 .
drwxr-xr-x 60 ken ken 4096 2010-09-04 08:49 ..
drwx------ 1 ken ken 4096 2010-06-05 07:34 sftp for ken on taylor13wl
taylor13wl is my netbook to which I am currently connected.

To make the solution generic I believe I want to -exclude /home/ken/.gvfs That should fix the problem regardless of which computer(s) I might be connected to during the backup. I will give it a try.

Ken
 
Old 09-04-2010, 09:41 AM   #8
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
Well I though I was on to something Here is my test command
Quote:
ken@taylor12:~$ tar -cvpzf --exclude=/home/ken/.gvfs /quitelarge/home-ken.gz /home/ken 2>> /quitelarge/tar-error.log
which results in the following errors
Quote:
tar: Removing leading `/' from member names
tar: /quitelarge/home-ken.gz: Cannot stattar: --exclude=/home/ken/.gvfs: Cannot open: No such file or directory
: No such file or directory
tar: Error is not recoverable: exiting now
I tried placing the path I wished to exclude (/home/ken/.gvfs) in a file (/quitelarge/excudethiscrap) and issued this command
Quote:
ken@taylor12:~$ tar -cvpzf --exclude=/quitelarge/excludethiscrap /quitelarge/home-ken.gz /home/ken 2>> /quitelarge/tar-error.log
which resulted in
Quote:
tar: Removing leading `/' from member names
tar: /quitelarge/home-ken.gz: Cannot stattar: --exclude=/quitelarge/excludethiscrap: Cannot open: No such file or directory
: No such file or directory
tar: Error is not recoverable: exiting now
removing the = sign allowed the process to run although it tried to archive the entire remote computer.

Ken
 
Old 09-04-2010, 10:00 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
'tar -${args}f /path/to/ball.tar --exclude /path/to/file --exclude /path/to/dir /path/to/tarsource' works for me OK.
 
Old 09-04-2010, 12:43 PM   #10
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
Perhaps it is because .gvfs is a hidden subdirectory???

Ken
 
Old 09-04-2010, 03:48 PM   #11
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Code:
sudo tar -cvpzf /quitelarge/home-ken.tgz  --exclude=/home/ken/.gvfs  /home/ken 2>> /quitelarge/tar-error.log
I rewrote your code so this one should work for you

try this assuming you have a folder quitelarge in your / direcotry.
 
Old 09-04-2010, 04:18 PM   #12
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
Thanks jmc1987, that worked (without the sudo - I own everything in my home directory tree). I have looked at several man pages for tar. None of them seem to describe any specific order or precedence for options, operators, operands etc. At least this information did not jump out at me.

I have incorporated the syntax you provided in my script.

Thanks again,

Ken

p.s. /quitelarge is /dev/sdb1 - my 750 GB drive and /veryhuge is /dev/sdc1 my 1 TB drive. /, /home, /data and swap are on my 10k RPM Velociraptor 150 GB drive. And despite an i7-860 quad processor and 8 GB of RAM my Atom processor netbook boots Ubuntu 9.04 faster than this pig of a desktop boots 10.04. Oh well.
 
Old 09-04-2010, 05:00 PM   #13
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Hmm no sudo. I guess you own that folder quitelarge

Glad to see if it works. But the credit belongs mostly to linuxquestions.org. They've help me most with that pesky tar command.

just to add you didn't need that part of the command "2>> /quitelarge/tar-error.log". I put it there just it case you wanted your errors logged.
Good luck to you.

Last edited by jmc1987; 09-04-2010 at 05:02 PM.
 
Old 09-04-2010, 07:45 PM   #14
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,398

Original Poster
Rep: Reputation: 101Reputation: 101
I have found the error logging to be helpful. In fact when I first developed the script it showed me a couple of files in my home tree which I did not own. Don't remember what the were but I own them now!

I paid for /quitelarge so I guess I should own it The machine is a Dell XPS 8000. It came with the 750 GB drive and Windoze 7 (after a month of waiting and raising H with Dell.) I had the Velociraptor waiting - had purchased it on sale from newegg. I had been looking for an external hard drive docking gizmo (insert the drive and plug the cable into USB.) Around New Years day newegg had the dock and a WD Black Caviar 1 TB drive for something like $79. Normal price of the dock was about $35 - what a deal. So now the machine is full of storage - well actually over full. One of the drives is in a floppy drive bay.

The machine is quite powerful. The only real problems I have with it are suspend (which does suspend but often does not wake up correctly - I find I am logged out) and printing some pdf files such as my statement from Citicards. The only way I can print it is to use the "genuine" Acrobat reader in a Win 7 virtual machine running under VMWare. No Linux pdf reader nor Foxit on XP will print the dang thing. Same with some pdfs I created with Xsane using my scanner. Created them in Linux, can view them in Linux but not print.

Ken
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
where is TAR ? bash: tar: command not found Juicyapple Linux - Newbie 7 06-10-2009 09:32 AM
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-14-2008 12:27 AM
tar command alias command rlg Linux - Newbie 0 03-11-2008 08:21 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM


All times are GMT -5. The time now is 12:54 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration