On 14-Jan-2012 James Bensley wrote:
rsync has this option
Unfortunately rsync is not present on that system (SuSE Linux 8.2 installed in 2003). I should add that I'm doing this for a friend (predominantly a Windows user) who wants to dispose of the machine, but keep the files. I do not have access to the installation disks (and they may well have gone into a black hole by now).
Thanks for the suggestion! Ted.
On Jan 14, 2012 9:12 PM, "Ted Harding" Ted.Harding@wlandres.net wrote:
Greetings All, I am currently engaged in copying files from a desktop machine to an external USB hard drive.
The machine has both Windows 98 and Linux on it, and dual-boots. Because Win98 does not recognise the external drive, while the Linux installation does, I'm booting into Linux to do the copying.
The objective is to transfer every file on the desktop onto the external drive. The external drive is mounted as /media/sda1 in Linux, and has a vfat filesystem.
The Windows drives \C, \D, \E, \F are mounted, when the machine is booted into Linux, as:
/windows/C /windows/D ... /windows/F
With the Windows files, no problem: I make the directories /media/sda1/WinLinMachine/C (and similar for .../D, .../E, .../F, these being all the Windows drives). Then I do the likes of:
cd /windows/C cp -a * /media/sda1/WinLinMachine/C
(and similar for D, E and F). This has worked fine. However, I now want to copy over all the Linux files as well. I have made a directory
/media/sda1/WinLinMachine/LinuxFiles
but now, of course,
cp -a /* /media/sda1/WinLinMachine/LinuxFiles
will not work, because the external drive is mounted under / and so will be itself copied and recopied in an infinite recursion. There would be no problem if there was an "exclude" option for 'cp' (say "-X") so that
cp -a -X /media /* /media/sda1/WinLinMachine/LinuxFiles
would inhibit anything under /media from being copied. But I can find no such option for 'cp'.
So how to proceed???
With thanks, Ted.
E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 14-Jan-2012 Time: 20:49:49
This message was sent by XFMail
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
---------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 14-Jan-2012 Time: 22:07:57
This message was sent by XFMail ----------------------------------
On 14/01/12 22:11, (Ted Harding) wrote:
On 14-Jan-2012 James Bensley wrote:
rsync has this option
Unfortunately rsync is not present on that system (SuSE Linux 8.2 installed in 2003). I should add that I'm doing this for a friend (predominantly a Windows user) who wants to dispose of the machine, but keep the files. I do not have access to the installation disks (and they may well have gone into a black hole by now).
Thanks for the suggestion! Ted.
The top link in that URL has several answers, one IIRC involves using find to "find" all the files, and pipes that through to a copy operation...
http://stackoverflow.com/questions/4585929/how-to-use-cp-command-to-exclude-...
or a "tar" example too.
HTH Steve
On 14-Jan-2012 steve-ALUG@hst.me.uk wrote:
On 14/01/12 22:11, (Ted Harding) wrote:
On 14-Jan-2012 James Bensley wrote:
rsync has this option
Unfortunately rsync is not present on that system (SuSE Linux 8.2 installed in 2003). I should add that I'm doing this for a friend (predominantly a Windows user) who wants to dispose of the machine, but keep the files. I do not have access to the installation disks (and they may well have gone into a black hole by now).
Thanks for the suggestion! Ted.
The top link in that URL has several answers, one IIRC involves using find to "find" all the files, and pipes that through to a copy operation...
http://stackoverflow.com/questions/4585929/how-to-use-cp-command-to-exclude-... specific-directory
or a "tar" example too.
HTH Steve
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
---------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 14-Jan-2012 Time: 22:32:13
This message was sent by XFMail ----------------------------------
On 14/01/2012 22:33, (Ted Harding) wrote:
[SNIP]
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
I'd advise using tar too. These are from my notes:
---- cut here ---- #### To copy a directory tree with tar:
cd fromdir; tar cf - . | (cd todir; tar xfBp -)
copy all files and subdirectories in "fromdir" to "todir". Note target dir must exist. Note the use of "-" with pipe. N.B. this is how you move a directory between discs. #### To copy all of the files and subdirectories in the current working directory to the #### directory /target, use:
tar cf - * | ( cd /target; tar xfp -) ---- cut here ----
Obviously, you need to add in the exclude part from Keith's suggestion.
Cheers, Laurie.
On 15-Jan-2012 Laurie Brown wrote:
On 14/01/2012 22:33, (Ted Harding) wrote:
[SNIP]
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
I'd advise using tar too. These are from my notes:
---- cut here ---- #### To copy a directory tree with tar:
cd fromdir; tar cf - . | (cd todir; tar xfBp -)
copy all files and subdirectories in "fromdir" to "todir". Note target dir must exist. Note the use of "-" with pipe. N.B. this is how you move a directory between discs.
#### To copy all of the files and subdirectories in the current working directory to the #### directory /target, use:
tar cf - * | ( cd /target; tar xfp -) ---- cut here ----
Obviously, you need to add in the exclude part from Keith's suggestion.
Cheers, Laurie.
One question about this kind of approach. The above pipe is written as though the "tar cf - *" part is completed before the output is piped to the "( cd /target; tar xfp -)" part (I'm guessing this because of the "cd" element of the second part). So, supposing the tar archive from "tar cf - *" is very big (as it would be in this case, far exceeding the RAM and swap space), would that cause problems?
Ted. ---------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 15-Jan-2012 Time: 13:09:14
This message was sent by XFMail ----------------------------------
On 15/01/2012 13:16, Keith Edmunds wrote:
On Sun, 15 Jan 2012 13:14:30 -0000 (GMT), Ted.Harding@wlandres.net said:
would that cause problems?
No.
Agreed. I've used those snippets dozens and dozens of times, often on huge amounts of data.
Cheers, Laurie.
On 15/01/12 13:14, (Ted Harding) wrote:
On 15-Jan-2012 Laurie Brown wrote:
On 14/01/2012 22:33, (Ted Harding) wrote:
[SNIP]
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
I'd advise using tar too. These are from my notes:
---- cut here ---- #### To copy a directory tree with tar:
cd fromdir; tar cf - . | (cd todir; tar xfBp -)
copy all files and subdirectories in "fromdir" to "todir". Note target dir must exist. Note the use of "-" with pipe. N.B. this is how you move a directory between discs.
#### To copy all of the files and subdirectories in the current working directory to the #### directory /target, use:
tar cf - * | ( cd /target; tar xfp -) ---- cut here ----
Obviously, you need to add in the exclude part from Keith's suggestion.
Cheers, Laurie.
One question about this kind of approach. The above pipe is written as though the "tar cf - *" part is completed before the output is piped to the "( cd /target; tar xfp -)" part (I'm guessing this because of the "cd" element of the second part). So, supposing the tar archive from "tar cf - *" is very big (as it would be in this case, far exceeding the RAM and swap space), would that cause problems?
Ted.
It won't cause a problem because the two halves of the operation take place in parallel. When the shell sees the pipe (|) it will use fork to start the left and right hand halves as separate processes. The left half will not touch the current directory and will build a TAR archive of the files and send this to standard out (the pipe). On the right hand side the cd will execute first thus changing the current directory of the process executing the right hand side. As the current directory is specific to process this will not affect the left hand side or the shell. After doing that tar will read the archive from standard input (the pipe) and unpack it into the new directory.
On 16-Jan-2012 Steve Fosdick wrote:
On 15/01/12 13:14, (Ted Harding) wrote:
On 15-Jan-2012 Laurie Brown wrote:
On 14/01/2012 22:33, (Ted Harding) wrote:
[SNIP]
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
I'd advise using tar too. These are from my notes:
---- cut here ---- #### To copy a directory tree with tar:
cd fromdir; tar cf - . | (cd todir; tar xfBp -)
copy all files and subdirectories in "fromdir" to "todir". Note target dir must exist. Note the use of "-" with pipe. N.B. this is how you move a directory between discs.
#### To copy all of the files and subdirectories in the current working directory to the #### directory /target, use:
tar cf - * | ( cd /target; tar xfp -) ---- cut here ----
Obviously, you need to add in the exclude part from Keith's suggestion.
Cheers, Laurie.
One question about this kind of approach. The above pipe is written as though the "tar cf - *" part is completed before the output is piped to the "( cd /target; tar xfp -)" part (I'm guessing this because of the "cd" element of the second part). So, supposing the tar archive from "tar cf - *" is very big (as it would be in this case, far exceeding the RAM and swap space), would that cause problems?
Ted.
It won't cause a problem because the two halves of the operation take place in parallel. When the shell sees the pipe (|) it will use fork to start the left and right hand halves as separate processes. The left half will not touch the current directory and will build a TAR archive of the files and send this to standard out (the pipe). On the right hand side the cd will execute first thus changing the current directory of the process executing the right hand side. As the current directory is specific to process this will not affect the left hand side or the shell. After doing that tar will read the archive from standard input (the pipe) and unpack it into the new directory.
Thanks, Steve, that's exactly the explanation I need! Thanks also to everyone else who joined in. It has been a really useful discussion for me.
As it happens, I have just heard from my friend that they don't need the Linux partition to be archived anyway, so I'm no longer facing the problem. But I have learned a lot, so it wasn't a waste of anyone's time!
Best wishes, Ted.
------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 16-Jan-2012 Time: 20:04:47 This message was sent by XFMail -------------------------------------------------