LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-11-2013, 08:16 AM   #1
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
Archiving Files and Directories and Preserving their Complete Path Info


Hi,


We have directories and sub-directories and files and under

/var/myapp/

and need to move only those files which are older than 90 days.

While moving them to

/tmp/myapp/

we need to make sure that the complete hierarchy of the file / directory is also maintained such that

/var/myapp/project1/fil1 ... file9 ... dir1 .. dir2 ..

are moved to /tmp/myapp as

/tmp/myapp/project1/fil1 ... file2 ...n ... dir1 ... dir2..

Actually, we need to archive / compress the files older than 90 days and also maintain the hierarchy in the compressed file containing all the matched directories / files as found by the command find:

Code:
find /var/myapp -mtime +90
So, how do I archive the files / directories returned by the above command in a way that when they are archived under /tmp/myapp they have their complete path as shown below:

/tmp/myapp/project1.gz

and project.gz when decompressed / untarred it should show the complete path.
 
Old 09-11-2013, 11:34 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Depending on if you gave a lot of files to search it may actually be easier to use a recursive copy which would preserve the hierarchy and then delete the files you don't want.
 
  


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
Manipulating with files, directories / archiving via the Command Line GR14 Linux - Newbie 16 01-22-2012 01:55 PM
[SOLVED] Zip files without complete path in the output Perseus Programming 5 10-26-2011 04:11 AM
Archiving old files from /home/* directories to less expensive disk storage. Cerephim Linux - Server 6 11-06-2009 11:25 AM
Encoding mp3s and preserving meta info ErrorBound Linux - Software 2 10-28-2007 12:10 AM

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

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