LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-20-2008, 09:56 AM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Redundant Directory Copy w/ Tar


Hello everyone!

I am attempting to copy all my data from my work PC to a backup file server in the office. Now when for some reason when I run the following command on my work PC to copy all my files to my backup server, I am not getting the desired result and I think there is something wrong with my command but I don't know what needs to be changed.

Please keep in mind that this is the 1st time I am running the command so that is why I did not start with Rsync however once a bulk of the files are moved over, then I will simply enable Rsync in Cron to keep the two machines synced.

The command I am running is:

Code:
time tar -cjf - --exclude=.* /home/carlwill/ | ssh root@10.1.1.29 tar -xpjvf - -C /backup/carlwill/
When I run the above command, every home/ directory is being recursivly moved to the destination server as well as mine which is not what I want. When all is said and done, I have the following on my backup server:

/backup/carlwill/home/carlwill

The bold above is redundant recursive directories moved from my command. I simply wanted all data from /home/carlwill/* to be moved into /backup/carlwill/ and nothing more.

What did I do wrong?
 
Old 03-20-2008, 10:30 AM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
you may want to try:
a) on tar creation using /home/carlwill/*

and/or

b) on tar extraction using [ --strip-components | --strip-path ] NUMBER (depending on your version of tar will depend on which option to use -- consult the man page)

This is off the top of my head so if you still have problems let me know and i'll set-up a mock env to test.



Code:
time tar -cjf - --exclude=.* /home/carlwill/* | ssh root@10.1.1.29 tar --strip-components 2 -xpjvf - -C /backup/carlwill/

Last edited by rayfordj; 03-20-2008 at 10:42 AM. Reason: added example code
 
Old 03-20-2008, 12:09 PM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
The problem is you give the complete path specification to tar. In this case tar will use the complete path to generate the backup, and, of course, to restore it.
The solution is to use a relative path specification.

Code:
time (cd /home/carwill; tar -cjf -  . ) | ssh root@10.1.1.29 tar -xpjvf - -C /backup/carlwill/
What do you trying to achieve using "exclude" ? I get lost and I omitted the "exclude" in my tip.
 
Old 03-20-2008, 12:30 PM   #4
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
I just wanted to copy all my physical files and folders. I don't want any of the system (hidden) files or folders that are associated with applications installed on my PC. I just want the meat and potatoes backed up.

I will try your command and see how I make out.

Thanks for helping!
 
  


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
Redundant directory levels with cifs bingo Linux - Software 3 02-28-2007 05:47 PM
Copy directory execlude directory linux2man Linux - General 3 12-12-2006 07:52 AM
need copy of tomcat 4 tar file Kaao Linux - Software 1 05-16-2006 12:20 PM
How to copy one directory to another directory thru PHP? green_njk Programming 1 01-06-2006 06:55 AM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 11:51 AM

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

All times are GMT -5. The time now is 02:55 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
Open Source Consulting | Domain Registration