Re: [Hampshire] Finding files not used in the last 365 days

Top Page
Author: Andy Smith
Date:  
To: hampshire
Subject: Re: [Hampshire] Finding files not used in the last 365 days

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x57c77100.hantslug.org.uk.2408': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Tue May 8 13:07:56 2007 BST
gpg: using DSA key 2099B64CBF15490B
gpg: Can't check signature: No public key
On Tue, May 08, 2007 at 12:00:22PM +0100, Brian Chivers wrote:
> I've just finished building a new server for our Admin staff but I don't
> really want to copy over all the data as a lot of it is really old.
>
> What I'd like to do is to move all the old stuff onto one of our less used
> servers or even an external HDD so we have it as an archive.
>
> The directory structure is something like this
>
> /home/admin/Marketing/xxxxxxxxxxxxx
>
> where xxxxxxxxxxxx is all the subdirectories & files that I'd like to move.
> It's more the files I'd like to move.
>
> I've worked out that I can use the "find" command with -mtine 365 extension


Do you really want to use mtime? What about files that are used
every day but not modified? If your filesystem isn't mounted
"noatime" then you could use -atime instead to do it by last access
time.

> but what I don't know how to do is the actual moving the files but
> maintaining the directory structure on the archive so something move them
> to something like
>
> /mount/achieve/Marketing/xxxxxxxxxxxxxx
>
> where xxxxxxxxxxxx is a duplicate of the directory structure that it's been
> moved from.


There's probably other ways, but you can use tar for this:

find /path -type f -atime +365 -print0 | xargs -0 tar pcf - | (cd /target && tar pxvf -)

you'll end up with a /target/path/... directory tree.

Cheers,
Andy

--
http://bitfolk.com/ -- No-nonsense VPS hosting
Encrypted mail welcome - keyid 0x604DE5DB

My words are my own and do not represent Jacqui Caren.