LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-27-2007, 11:48 AM   #1
pmetzak
LQ Newbie
 
Registered: Sep 2006
Posts: 10

Rep: Reputation: 0
backing up text files distributed throughout the drive


Hi,

I am attempting to back up a bunch of .m files that are located all over the 2 hard drives (these .m files are text files run by matlab). I have been doing a bit of research and its seems like cpio might be a good option.

Is this the command that I would use?

find -name "*.m" -print | cpio -ov > mfiles2007.cpio

Is there a better way to accomplish what I am setting out to do?

Thanks for any help you can offer me.

Paul
 
Old 02-27-2007, 12:40 PM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
My advise: Test the command out on a test collection first, just to be safe. Other then that i cant say, as cpio has no man page because GNU doesn't like man pages, so i have no clue if that command will work.
 
Old 02-27-2007, 12:52 PM   #3
dgar
Member
 
Registered: Jun 2005
Location: Candia, NH
Distribution: Ubuntu, FC, RHE3, RHE4, CentOS
Posts: 121

Rep: Reputation: 15
It will work if you can guarantee that no directories or file names have spaces in them, unless CPIO handles spaces in stdin streams....

I'd use:
locate -r '\.mp3$' > filelist.txt
for line in $(cat filelist.txt); do
cp -v "$line" /some/destination/
done 2>&1 | tee copy_report.txt
 
Old 02-27-2007, 02:53 PM   #4
pmetzak
LQ Newbie
 
Registered: Sep 2006
Posts: 10

Original Poster
Rep: Reputation: 0
I'm sorry, I don't really understand this:

locate -r '\.mp3$' > filelist.txt
for line in $(cat filelist.txt); do
cp -v "$line" /some/destination/
done 2>&1 | tee copy_report.txt

Is this 2 commands separated by the semi-colon? Also, I only want .m files not .mp3's but I can figure out the substitution to make there myself

Once again, I apologize for my ignorance,

Paul
 
Old 02-27-2007, 03:50 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,297

Rep: Reputation: 126Reputation: 126
"find /data -name "*.ogg" -print | cpio -ov > test.cpio"

I just ran this against the ogg files in my data disk. They have embedded spaces, and it seemed to work just fine. I did a "cpio -tv < test.cpio", and it listed the files I expected, having substituted "\ " for the embedded spaces. Sometimes you just have to do it and see if it works.

Added:
Almost forgot: the man page sucks, but "cpio --help" or "cpio --usage" gives a lot of help.

Last edited by Quakeboy02; 02-27-2007 at 03:53 PM.
 
Old 02-28-2007, 08:22 AM   #6
dgar
Member
 
Registered: Jun 2005
Location: Candia, NH
Distribution: Ubuntu, FC, RHE3, RHE4, CentOS
Posts: 121

Rep: Reputation: 15
The 'find <options> | cpio <options>' is the most powerful, but also two of the oldest and most archaic commands in /usr/bin/*.

Let me break down my method:

locate -r '\.mp3$' > filelist.txt
# There is a database updated nightly of all filenames.
# The above makes a list of all files ending in '.mp3'
# The advantage is that you can just edit the list. b)

for line in $(cat filelist.txt); do
# This assigns each line of filelist.txt to $line.
# The semicolon is just a stylistic shorthand.

cp -v "$line" /some/destination/
# The meat of the command.
# I actually run 'cp -vn' first which
# pretends to copy, but doesn't actually do it.

done 2>&1 | tee copy_report.txt
# Some UNIX magic here. This ends the looping
# over filenames.txt and forks the output of
# 'cp -v' to both the screen and a logfile.
 
  


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
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 11:42 AM
Need to remove files distributed throughout system. DanTaylor Linux - General 3 04-05-2006 05:15 AM
Backing up Fedora Core 3 files to an NTFS Windows XP drive. Dark_Oppressor Linux - General 8 06-29-2005 09:13 PM
Backing up files with a USB Extrenal hard drive linuxmarine Red Hat 13 05-26-2005 08:33 PM
backing up data files to a DVD-RW drive Earl Parker II Slackware 6 08-12-2004 07:42 AM

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

All times are GMT -5. The time now is 09:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration